@reventlessdev/reventless-seed-aws 1.0.0-alpha.4 → 1.0.0-alpha.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 (37) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/bs/.compiler.log +2 -2
  3. package/lib/bs/.sourcedirs.json +1 -0
  4. package/lib/bs/compiler-info.json +2 -2
  5. package/lib/bs/src/ReventlessSeedAws.ast +0 -0
  6. package/lib/bs/src/ReventlessSeedAws.cmi +0 -0
  7. package/lib/bs/src/ReventlessSeedAws.cmj +0 -0
  8. package/lib/bs/src/ReventlessSeedAws.cmt +0 -0
  9. package/lib/bs/src/ReventlessSeedAws.res +125 -68
  10. package/lib/bs/src/ReventlessSeedAws.res.mjs +63 -30
  11. package/lib/bs/src/ReventlessSeedAws_Reset.cmi +0 -0
  12. package/lib/bs/src/ReventlessSeedAws_Reset.cmt +0 -0
  13. package/lib/bs/tests/EndpointResolutionTest.ast +0 -0
  14. package/lib/bs/tests/EndpointResolutionTest.cmi +0 -0
  15. package/lib/bs/tests/EndpointResolutionTest.cmj +0 -0
  16. package/lib/bs/tests/EndpointResolutionTest.cmt +0 -0
  17. package/lib/bs/tests/EndpointResolutionTest.res +181 -0
  18. package/lib/bs/tests/EndpointResolutionTest.res.mjs +208 -0
  19. package/lib/ocaml/.compiler.log +2 -2
  20. package/lib/ocaml/EndpointResolutionTest.ast +0 -0
  21. package/lib/ocaml/EndpointResolutionTest.cmi +0 -0
  22. package/lib/ocaml/EndpointResolutionTest.cmj +0 -0
  23. package/lib/ocaml/EndpointResolutionTest.cmt +0 -0
  24. package/lib/ocaml/EndpointResolutionTest.res +181 -0
  25. package/lib/ocaml/ReventlessSeedAws.ast +0 -0
  26. package/lib/ocaml/ReventlessSeedAws.cmi +0 -0
  27. package/lib/ocaml/ReventlessSeedAws.cmj +0 -0
  28. package/lib/ocaml/ReventlessSeedAws.cmt +0 -0
  29. package/lib/ocaml/ReventlessSeedAws.res +125 -68
  30. package/lib/ocaml/ReventlessSeedAws_Reset.cmi +0 -0
  31. package/lib/ocaml/ReventlessSeedAws_Reset.cmt +0 -0
  32. package/package.json +4 -3
  33. package/rescript.json +7 -1
  34. package/src/ReventlessSeedAws.res +125 -68
  35. package/src/ReventlessSeedAws.res.mjs +63 -30
  36. package/tests/EndpointResolutionTest.res +181 -0
  37. package/tests/EndpointResolutionTest.res.mjs +208 -0
@@ -0,0 +1,208 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as JestGlobals from "@reventlessdev/rescript-jest/src/JestGlobals.res.mjs";
4
+ import * as ReventlessSeedAws from "../src/ReventlessSeedAws.res.mjs";
5
+ import * as Seed$ReventlessSeed from "@reventlessdev/reventless-seed/src/Seed.res.mjs";
6
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
7
+
8
+ function clearOverrides() {
9
+ [
10
+ "REVENTLESS_GRAPHQL_ENDPOINT",
11
+ "REVENTLESS_UPLOAD_ENDPOINT",
12
+ "AWS_REGION",
13
+ "COGNITO_CLIENT_ID",
14
+ "SEED_SKIP_UPLOADS"
15
+ ].forEach(k => {
16
+ process.env[k] = "";
17
+ });
18
+ }
19
+
20
+ function obj(entries) {
21
+ return Object.fromEntries(entries);
22
+ }
23
+
24
+ function str(prim) {
25
+ return prim;
26
+ }
27
+
28
+ function config(extra) {
29
+ return Object.fromEntries([
30
+ [
31
+ "apiEndpoint",
32
+ "https://api.example/graphql"
33
+ ],
34
+ [
35
+ "region",
36
+ "eu-west-1"
37
+ ],
38
+ [
39
+ "cognitoClientId",
40
+ "client-abc"
41
+ ]
42
+ ].concat(extra));
43
+ }
44
+
45
+ function outputs(extra) {
46
+ return Object.fromEntries([
47
+ [
48
+ "domainApiEndpoint",
49
+ "https://domain.example/graphql"
50
+ ],
51
+ [
52
+ "cognitoRegion",
53
+ "eu-west-1"
54
+ ],
55
+ [
56
+ "cognitoUserPoolClientId",
57
+ "client-abc"
58
+ ]
59
+ ].concat(extra));
60
+ }
61
+
62
+ let storeEndpoints = Object.fromEntries([[
63
+ "Catalog.productImages",
64
+ "https://presign.example/"
65
+ ]]);
66
+
67
+ globalThis.describe("endpointsFrom — host shell arm", () => {
68
+ globalThis.beforeEach(clearOverrides);
69
+ globalThis.test("reads the legacy single service and the per-store map together", () => {
70
+ let eps = ReventlessSeedAws.endpointsFrom("alpha", {
71
+ TAG: "HostShellConfig",
72
+ _0: config([
73
+ [
74
+ "uploadEndpoint",
75
+ "https://legacy.example/"
76
+ ],
77
+ [
78
+ "uploadEndpoints",
79
+ storeEndpoints
80
+ ]
81
+ ])
82
+ });
83
+ globalThis.expect(eps.uploadEndpoint).toBe("https://legacy.example/");
84
+ globalThis.expect(eps.uploadEndpoints).toEqual(Object.fromEntries([[
85
+ "Catalog.productImages",
86
+ "https://presign.example/"
87
+ ]]));
88
+ });
89
+ globalThis.test("a shell publishing only per-store endpoints resolves an empty legacy service", () => {
90
+ let eps = ReventlessSeedAws.endpointsFrom("alpha", {
91
+ TAG: "HostShellConfig",
92
+ _0: config([[
93
+ "uploadEndpoints",
94
+ storeEndpoints
95
+ ]])
96
+ });
97
+ globalThis.expect(eps.uploadEndpoint).toBe("");
98
+ globalThis.expect(Object.keys(eps.uploadEndpoints)).toEqual(["Catalog.productImages"]);
99
+ });
100
+ globalThis.test("REVENTLESS_UPLOAD_ENDPOINT overrides the legacy service and leaves the map alone", () => {
101
+ process.env["REVENTLESS_UPLOAD_ENDPOINT"] = "https://override.example/";
102
+ let eps = ReventlessSeedAws.endpointsFrom("alpha", {
103
+ TAG: "HostShellConfig",
104
+ _0: config([
105
+ [
106
+ "uploadEndpoint",
107
+ "https://legacy.example/"
108
+ ],
109
+ [
110
+ "uploadEndpoints",
111
+ storeEndpoints
112
+ ]
113
+ ])
114
+ });
115
+ globalThis.expect(eps.uploadEndpoint).toBe("https://override.example/");
116
+ globalThis.expect(eps.uploadEndpoints["Catalog.productImages"]).toEqual("https://presign.example/");
117
+ });
118
+ });
119
+
120
+ globalThis.describe("endpointsFrom — stack outputs arm", () => {
121
+ globalThis.beforeEach(clearOverrides);
122
+ globalThis.test("reads the uploadEndpoints stack output", () => {
123
+ let eps = ReventlessSeedAws.endpointsFrom("pr-verify", {
124
+ TAG: "StackOutputs",
125
+ _0: outputs([[
126
+ "uploadEndpoints",
127
+ storeEndpoints
128
+ ]])
129
+ });
130
+ globalThis.expect(eps.uploadEndpoints).toEqual(Object.fromEntries([[
131
+ "Catalog.productImages",
132
+ "https://presign.example/"
133
+ ]]));
134
+ });
135
+ globalThis.test("a deployment declaring no store resolves an empty map without failing", () => {
136
+ let eps = ReventlessSeedAws.endpointsFrom("pr-verify", {
137
+ TAG: "StackOutputs",
138
+ _0: outputs([])
139
+ });
140
+ globalThis.expect(eps.uploadEndpoint).toBe("");
141
+ globalThis.expect(Object.keys(eps.uploadEndpoints)).toEqual([]);
142
+ });
143
+ globalThis.test("prefers the merged API endpoint over the per-plugin one", () => {
144
+ let eps = ReventlessSeedAws.endpointsFrom("pr-verify", {
145
+ TAG: "StackOutputs",
146
+ _0: outputs([[
147
+ "domainMergedApiEndpoint",
148
+ "https://merged.example/"
149
+ ]])
150
+ });
151
+ globalThis.expect(eps.graphql).toBe("https://merged.example/");
152
+ });
153
+ globalThis.test("fails naming both keys when the stack exports neither API endpoint", () => {
154
+ let val;
155
+ try {
156
+ val = ReventlessSeedAws.endpointsFrom("pr-verify", {
157
+ TAG: "StackOutputs",
158
+ _0: Object.fromEntries([[
159
+ "cognitoRegion",
160
+ "eu-west-1"
161
+ ]])
162
+ });
163
+ } catch (raw_msg) {
164
+ let msg = Primitive_exceptions.internalToException(raw_msg);
165
+ if (msg.RE_EXN_ID === Seed$ReventlessSeed.Failed) {
166
+ let msg$1 = msg._1;
167
+ globalThis.expect(msg$1).toContain("domainMergedApiEndpoint");
168
+ globalThis.expect(msg$1).toContain("domainApiEndpoint");
169
+ return;
170
+ }
171
+ throw msg;
172
+ }
173
+ JestGlobals.fail("expected endpointsFrom to fail");
174
+ });
175
+ });
176
+
177
+ globalThis.describe("endpointsFrom — malformed uploadEndpoints", () => {
178
+ globalThis.beforeEach(clearOverrides);
179
+ globalThis.test("drops a non-string member rather than the whole map", () => {
180
+ let eps = ReventlessSeedAws.endpointsFrom("pr-verify", {
181
+ TAG: "StackOutputs",
182
+ _0: outputs([[
183
+ "uploadEndpoints",
184
+ Object.fromEntries([
185
+ [
186
+ "Catalog.productImages",
187
+ "https://presign.example/"
188
+ ],
189
+ [
190
+ "Catalog.broken",
191
+ 7
192
+ ]
193
+ ])
194
+ ]])
195
+ });
196
+ globalThis.expect(Object.keys(eps.uploadEndpoints)).toEqual(["Catalog.productImages"]);
197
+ });
198
+ });
199
+
200
+ export {
201
+ clearOverrides,
202
+ obj,
203
+ str,
204
+ config,
205
+ outputs,
206
+ storeEndpoints,
207
+ }
208
+ /* storeEndpoints Not a pure module */