@reventlessdev/reventless-aws 3.0.0-alpha.346 → 3.0.0-alpha.347

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 (80) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/package.json +17 -13
  3. package/rescript.json +2 -1
  4. package/run-bake-manifest.mjs +3 -0
  5. package/run-deploy-app.mjs +3 -0
  6. package/scripts/BakeManifest.res +395 -0
  7. package/scripts/BakeManifest.res.mjs +487 -0
  8. package/scripts/DeployApp.res +708 -0
  9. package/scripts/DeployApp.res.mjs +1015 -0
  10. package/scripts/DeployManifest.res +84 -0
  11. package/scripts/DeployManifest.res.mjs +112 -0
  12. package/scripts/ProvisionAccounts.res +60 -46
  13. package/scripts/ProvisionAccounts.res.mjs +51 -37
  14. package/scripts/PulumiCli.res +43 -0
  15. package/scripts/PulumiCli.res.mjs +106 -0
  16. package/src/Platform.res +19 -2
  17. package/src/Platform.res.mjs +12 -4
  18. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res +1 -5
  19. package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res.mjs +1 -1
  20. package/src/adapter/Api/Platform_UIFragments_Lambda.res +1 -5
  21. package/src/adapter/Api/Platform_UIFragments_Lambda.res.mjs +1 -2
  22. package/src/adapter/Auth/Auth_ActiveRoleStore.res +1 -5
  23. package/src/adapter/Auth/Auth_ActiveRoleStore.res.mjs +1 -2
  24. package/src/adapter/Auth/Auth_ActiveRoleTrigger.res +1 -5
  25. package/src/adapter/Auth/Auth_ActiveRoleTrigger.res.mjs +1 -2
  26. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res +52 -31
  27. package/src/adapter/DcbEventLog/DcbEventLogStorage_DynamoDb_Runtime.res.mjs +75 -44
  28. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res +1 -5
  29. package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res.mjs +1 -2
  30. package/src/adapter/Geocoder/Geocoder_AwsLocation_Resolver.res +1 -5
  31. package/src/adapter/Geocoder/Geocoder_AwsLocation_Resolver.res.mjs +1 -2
  32. package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res +5 -4
  33. package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res.mjs +1 -1
  34. package/src/adapter/Postgres/PgMigration_Builder.res +1 -1
  35. package/src/adapter/Postgres/PgMigration_Builder.res.mjs +1 -2
  36. package/src/adapter/Runtime/CommandGeneratorEntryPoint_Ops.res +2 -0
  37. package/src/adapter/Runtime/CommandGeneratorEntryPoint_Ops.res.mjs +2 -2
  38. package/src/adapter/Runtime/DcbCommandTopicEntryPoint.mjs +15 -6
  39. package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res +51 -30
  40. package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res.mjs +31 -14
  41. package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res +1 -5
  42. package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res.mjs +1 -1
  43. package/src/adapter/StateTopic/StateTopic_AppSync.res +1 -5
  44. package/src/adapter/StateTopic/StateTopic_AppSync.res.mjs +1 -1
  45. package/src/adapter/Task/TaskBucket_S3.res +1 -3
  46. package/src/adapter/Task/TaskBucket_S3.res.mjs +1 -1
  47. package/src/adapter/Upload/Upload_Claim_S3.res +1 -5
  48. package/src/adapter/Upload/Upload_Claim_S3.res.mjs +1 -1
  49. package/src/adapter/Upload/Upload_Presign_S3.res +1 -5
  50. package/src/adapter/Upload/Upload_Presign_S3.res.mjs +1 -2
  51. package/src/capability/Capability_Geocoding_AwsLocation.res +5 -1
  52. package/src/capability/Capability_Geocoding_AwsLocation.res.mjs +7 -1
  53. package/src/components/Api/AppSync_SdlDecorate.res +4 -2
  54. package/src/components/Api/AppSync_SdlDecorate.res.mjs +1 -1
  55. package/src/plugin/cloner/ClonerRunner_Fargate.res +1 -5
  56. package/src/plugin/cloner/ClonerRunner_Fargate.res.mjs +1 -1
  57. package/src/plugin/stack/Plugin_Stack.res +4 -0
  58. package/src/plugin/stack/Plugin_Stack.res.mjs +2 -0
  59. package/src/util/Util_DeadLetterQueue.res +1 -5
  60. package/src/util/Util_DeadLetterQueue.res.mjs +1 -2
  61. package/src/util/Util_StoreLayout.res +15 -2
  62. package/src/util/Util_StoreLayout.res.mjs +11 -3
  63. package/tests/BakeManifestTest.res +204 -0
  64. package/tests/BakeManifestTest.res.mjs +259 -0
  65. package/tests/DcbColdStartPartitionTest.res +32 -0
  66. package/tests/DcbColdStartPartitionTest.res.mjs +33 -0
  67. package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res +88 -0
  68. package/tests/DcbEventLogStorage_DynamoDb_RuntimeTest.res.mjs +112 -0
  69. package/tests/DcbUnresolvedPartitionSlice.res +28 -0
  70. package/tests/DcbUnresolvedPartitionSlice.res.mjs +38 -0
  71. package/tests/DeployAppTest.res +90 -0
  72. package/tests/DeployAppTest.res.mjs +133 -0
  73. package/tests/LambdaLayerLookupTest.res +104 -0
  74. package/tests/LambdaLayerLookupTest.res.mjs +117 -0
  75. package/tests/ProvisionAccountsTest.res +26 -0
  76. package/tests/ProvisionAccountsTest.res.mjs +31 -0
  77. package/tests/Util_StoreLayoutTest.res +6 -0
  78. package/tests/Util_StoreLayoutTest.res.mjs +7 -4
  79. package/tests/dcbColdStartPartition.mjs +66 -0
  80. package/tests/setup/layerArn.cjs +5 -0
@@ -1,5 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Nodefs from "node:fs";
4
+ import * as Nodeos from "node:os";
5
+ import * as Nodepath from "node:path";
3
6
  import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
4
7
  import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
5
8
  import * as ProvisionAccounts$ReventlessAws from "../scripts/ProvisionAccounts.res.mjs";
@@ -145,6 +148,34 @@ globalThis.describe("ProvisionAccounts.looksLikeEmail", () => {
145
148
  });
146
149
  });
147
150
 
151
+ globalThis.describe("ProvisionAccounts.provision", () => {
152
+ let manifest = `# the cast
153
+ - username: shopper
154
+ password: ""
155
+ groups: [Shopper]
156
+ `;
157
+ globalThis.test("a refused pool leaves the manifest untouched", async () => {
158
+ let dir = Nodefs.mkdtempSync(Nodepath.join(Nodeos.tmpdir(), "provision-accounts-"));
159
+ let file = Nodepath.join(dir, "users.yaml");
160
+ Nodefs.writeFileSync(file, manifest, "utf8");
161
+ let refuse = async (param, param$1) => ({
162
+ TAG: "Error",
163
+ _0: "pool signs in on email"
164
+ });
165
+ let outcome = await ProvisionAccounts$ReventlessAws.provision(file, "eu-west-1_Refuses", refuse);
166
+ let after = Nodefs.readFileSync(file, "utf8");
167
+ Nodefs.rmSync(dir, {
168
+ recursive: true,
169
+ force: true
170
+ });
171
+ globalThis.expect(outcome).toEqual({
172
+ TAG: "Error",
173
+ _0: "pool signs in on email"
174
+ });
175
+ globalThis.expect(after).toBe(manifest);
176
+ });
177
+ });
178
+
148
179
  let Provision;
149
180
 
150
181
  export {
@@ -179,6 +179,12 @@ describe("Util_StoreLayout.protectionFor", () => {
179
179
  testSync("'prepare' is not a PR stack — the prefix is 'pr-', not 'pr'", () =>
180
180
  expect(Util_StoreLayout.protectionFor(~stack="prepare"))->toEqual(Util_StoreLayout.Protected)
181
181
  )
182
+
183
+ testSync("a stack declared disposable is unprotected whatever its name", () =>
184
+ expect(Util_StoreLayout.protectionFor(~stack="dev", ~disposable=true))->toEqual(
185
+ Util_StoreLayout.Unprotected,
186
+ )
187
+ )
182
188
  })
183
189
 
184
190
  describe("Util_StoreLayout.bucketNameFor", () => {
@@ -87,16 +87,19 @@ globalThis.describe("Util_StoreLayout.coverageFor", () => {
87
87
  globalThis.describe("Util_StoreLayout.protectionFor", () => {
88
88
  globalThis.test("alpha shares a bucket and is still protected", () => {
89
89
  globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("alpha", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("SharedBucket");
90
- globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("alpha", undefined)).toEqual("Protected");
90
+ globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("alpha", undefined, undefined)).toEqual("Protected");
91
91
  });
92
92
  globalThis.test("prod is protected", () => {
93
- globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prod", undefined)).toEqual("Protected");
93
+ globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prod", undefined, undefined)).toEqual("Protected");
94
94
  });
95
95
  globalThis.test("a PR stack is unprotected so teardown does not leak buckets", () => {
96
- globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("pr-42", undefined)).toEqual("Unprotected");
96
+ globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("pr-42", undefined, undefined)).toEqual("Unprotected");
97
97
  });
98
98
  globalThis.test("'prepare' is not a PR stack — the prefix is 'pr-', not 'pr'", () => {
99
- globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prepare", undefined)).toEqual("Protected");
99
+ globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prepare", undefined, undefined)).toEqual("Protected");
100
+ });
101
+ globalThis.test("a stack declared disposable is unprotected whatever its name", () => {
102
+ globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("dev", true, undefined)).toEqual("Unprotected");
100
103
  });
101
104
  });
102
105
 
@@ -0,0 +1,66 @@
1
+ // Harness for DcbColdStartPartitionTest.
2
+ //
3
+ // Startup runs when the entry point is first imported, reading HANDLER_CONFIG from
4
+ // the environment — so the failed-startup case has to set it before that import,
5
+ // which only plain ESM can do. The assertions stay in the .res test.
6
+
7
+ const ENTRY = "../src/adapter/Runtime/DcbCommandTopicEntryPoint.mjs";
8
+
9
+ const baseConfig = {
10
+ pluginName: "ColdStartTestPlugin",
11
+ dcbEventLogTableName: "cold-start-test-table",
12
+ queueUrl: "https://sqs.eu-west-1.amazonaws.com/000000000000/cold-start-test-queue",
13
+ inboundTranslationSliceModules: [],
14
+ };
15
+
16
+ const messageOf = (err) => (err instanceof Error ? err.message : String(err));
17
+
18
+ // Imports the entry point with a registry it cannot load, then calls `handler`
19
+ // twice. Returns both rejection messages and any rejection nobody handled.
20
+ export async function invokeAfterFailedStartup() {
21
+ const unhandled = [];
22
+ const onUnhandled = (reason) => unhandled.push(messageOf(reason));
23
+ process.on("unhandledRejection", onUnhandled);
24
+ process.env.HANDLER_CONFIG = JSON.stringify({
25
+ ...baseConfig,
26
+ stateChangeSliceModules: [{ spec: "cold-start-test/missing-spec.mjs", behavior: "cold-start-test/missing-behavior.mjs" }],
27
+ });
28
+ try {
29
+ const { handler } = await import(ENTRY);
30
+ // Let the startup rejection settle before anyone awaits it.
31
+ await new Promise((resolve) => setTimeout(resolve, 50));
32
+ const messages = [];
33
+ for (let i = 0; i < 2; i++) {
34
+ try {
35
+ await handler({ Records: [] }, { awsRequestId: `call-${i}` });
36
+ messages.push("resolved");
37
+ } catch (err) {
38
+ messages.push(messageOf(err));
39
+ }
40
+ }
41
+ return { messages, unhandled };
42
+ } finally {
43
+ delete process.env.HANDLER_CONFIG;
44
+ process.off("unhandledRejection", onUnhandled);
45
+ }
46
+ }
47
+
48
+ // Builds the handlers for a boundary holding one slice whose partition cannot be
49
+ // inferred. Returns the rejection message, or "started".
50
+ export async function startWithUnresolvedSlice() {
51
+ const { buildHandlersForConfig } = await import(ENTRY);
52
+ const loadModule = async (specifier) => {
53
+ if (specifier === "cold-start-test://spec") return await import("./DcbUnresolvedPartitionSlice.res.mjs");
54
+ if (specifier === "cold-start-test://behavior") return {};
55
+ throw new Error("unknown test specifier: " + specifier);
56
+ };
57
+ try {
58
+ await buildHandlersForConfig(
59
+ { ...baseConfig, stateChangeSliceModules: [{ spec: "cold-start-test://spec", behavior: "cold-start-test://behavior" }] },
60
+ { loadModule },
61
+ );
62
+ return "started";
63
+ } catch (err) {
64
+ return messageOf(err);
65
+ }
66
+ }
@@ -0,0 +1,5 @@
1
+ // A deploy stops when no Reventless layer is found, and these suites create
2
+ // functions — some at import time — so they get a stand-in rather than a lookup
3
+ // in whatever AWS account the shell happens to reach.
4
+ process.env.REVENTLESS_LAYER_ARN =
5
+ "arn:aws:lambda:eu-central-1:000000000000:layer:reventless-test:1";