@reventlessdev/reventless-aws 3.0.0-alpha.238 → 3.0.0-alpha.240
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 +15 -0
- package/package.json +6 -6
- package/src/Platform.res +173 -15
- package/src/Platform.res.mjs +220 -32
- package/src/adapter/Upload/Upload_Presign_S3.res +19 -3
- package/src/adapter/Upload/Upload_Presign_S3.res.mjs +9 -9
- package/src/capability/Capability_ObjectStore_S3.res +69 -7
- package/src/capability/Capability_ObjectStore_S3.res.mjs +32 -6
- package/src/plugin/stack/Plugin_Stack.res +19 -6
- package/src/plugin/stack/Plugin_Stack.res.mjs +6 -6
- package/src/util/Util_HostUiDomain.res +17 -0
- package/src/util/Util_HostUiDomain.res.mjs +8 -1
- package/src/util/Util_StoreLayout.res +104 -0
- package/src/util/Util_StoreLayout.res.mjs +42 -0
- package/tests/Util_StoreLayoutTest.res +115 -0
- package/tests/Util_StoreLayoutTest.res.mjs +69 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
open JestGlobals
|
|
2
|
+
|
|
3
|
+
let prodStacks = Util_HostUiDomain.defaultProdStacks
|
|
4
|
+
|
|
5
|
+
describe("Util_StoreLayout.layoutFor", () => {
|
|
6
|
+
testSync("a prod-named stack gets a bucket per store", () =>
|
|
7
|
+
expect(Util_StoreLayout.layoutFor(~stack="prod", ~prodStacks))->toEqual(Util_StoreLayout.PerStore)
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
testSync("'main' is production too, by the shared prod list", () =>
|
|
11
|
+
expect(Util_StoreLayout.layoutFor(~stack="main", ~prodStacks))->toEqual(Util_StoreLayout.PerStore)
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
testSync("alpha shares one bucket", () =>
|
|
15
|
+
expect(Util_StoreLayout.layoutFor(~stack="alpha", ~prodStacks))->toEqual(
|
|
16
|
+
Util_StoreLayout.SharedBucket,
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
testSync("a PR stack shares one bucket — the factor that multiplies", () =>
|
|
21
|
+
expect(Util_StoreLayout.layoutFor(~stack="pr-1234", ~prodStacks))->toEqual(
|
|
22
|
+
Util_StoreLayout.SharedBucket,
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
// The accepted fail-open: a production stack whose name is not on the list
|
|
27
|
+
// gets the weaker layout silently. Asserted so the behaviour is a decision on
|
|
28
|
+
// record rather than a surprise, and so the config override is the documented
|
|
29
|
+
// fix rather than a code change.
|
|
30
|
+
testSync("an unlisted production name falls open to the shared layout", () =>
|
|
31
|
+
expect(Util_StoreLayout.layoutFor(~stack="production", ~prodStacks))->toEqual(
|
|
32
|
+
Util_StoreLayout.SharedBucket,
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
testSync("adding it to the prod list is the fix", () =>
|
|
37
|
+
expect(Util_StoreLayout.layoutFor(~stack="production", ~prodStacks=["prod", "production"]))->toEqual(
|
|
38
|
+
Util_StoreLayout.PerStore,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe("Util_StoreLayout.protectionFor", () => {
|
|
44
|
+
// The pairing a single layout-driven switch would have got wrong: alpha
|
|
45
|
+
// shares a bucket and is still protected.
|
|
46
|
+
testSync("alpha shares a bucket and is still protected", () => {
|
|
47
|
+
expect(Util_StoreLayout.layoutFor(~stack="alpha", ~prodStacks))->toEqual(
|
|
48
|
+
Util_StoreLayout.SharedBucket,
|
|
49
|
+
)
|
|
50
|
+
expect(Util_StoreLayout.protectionFor(~stack="alpha"))->toEqual(Util_StoreLayout.Protected)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
testSync("prod is protected", () =>
|
|
54
|
+
expect(Util_StoreLayout.protectionFor(~stack="prod"))->toEqual(Util_StoreLayout.Protected)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
testSync("a PR stack is unprotected so teardown does not leak buckets", () =>
|
|
58
|
+
expect(Util_StoreLayout.protectionFor(~stack="pr-42"))->toEqual(Util_StoreLayout.Unprotected)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
testSync("'prepare' is not a PR stack — the prefix is 'pr-', not 'pr'", () =>
|
|
62
|
+
expect(Util_StoreLayout.protectionFor(~stack="prepare"))->toEqual(Util_StoreLayout.Protected)
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe("Util_StoreLayout.bucketNameFor", () => {
|
|
67
|
+
testSync("per-store names the bucket after the declaration", () =>
|
|
68
|
+
expect(
|
|
69
|
+
Util_StoreLayout.bucketNameFor(
|
|
70
|
+
~layout=PerStore,
|
|
71
|
+
~stack="prod",
|
|
72
|
+
~plugin="catalog",
|
|
73
|
+
~store="productImages",
|
|
74
|
+
),
|
|
75
|
+
)->toBe("catalog-productImages")
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
testSync("shared names one bucket per stack", () =>
|
|
79
|
+
expect(
|
|
80
|
+
Util_StoreLayout.bucketNameFor(
|
|
81
|
+
~layout=SharedBucket,
|
|
82
|
+
~stack="alpha",
|
|
83
|
+
~plugin="catalog",
|
|
84
|
+
~store="productImages",
|
|
85
|
+
),
|
|
86
|
+
)->toBe("alpha-stores")
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
testSync("every store on a shared stack lands in the same bucket", () =>
|
|
90
|
+
expect(
|
|
91
|
+
Util_StoreLayout.bucketNameFor(
|
|
92
|
+
~layout=SharedBucket,
|
|
93
|
+
~stack="alpha",
|
|
94
|
+
~plugin="ordering",
|
|
95
|
+
~store="invoices",
|
|
96
|
+
),
|
|
97
|
+
)->toBe(
|
|
98
|
+
Util_StoreLayout.bucketNameFor(
|
|
99
|
+
~layout=SharedBucket,
|
|
100
|
+
~stack="alpha",
|
|
101
|
+
~plugin="catalog",
|
|
102
|
+
~store="productImages",
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe("Util_StoreLayout.keyPrefixFor", () => {
|
|
109
|
+
// The assertion the whole dual-layout scheme rests on: a ref is
|
|
110
|
+
// layout-independent, so the same declaration produces the same stored string
|
|
111
|
+
// on a per-store stack and a shared one.
|
|
112
|
+
testSync("the key prefix is the store name in both layouts", () =>
|
|
113
|
+
expect(Util_StoreLayout.keyPrefixFor(~store="productImages"))->toBe("productImages")
|
|
114
|
+
)
|
|
115
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Util_StoreLayout$ReventlessAws from "../src/util/Util_StoreLayout.res.mjs";
|
|
4
|
+
import * as Util_HostUiDomain$ReventlessAws from "../src/util/Util_HostUiDomain.res.mjs";
|
|
5
|
+
|
|
6
|
+
globalThis.describe("Util_StoreLayout.layoutFor", () => {
|
|
7
|
+
globalThis.test("a prod-named stack gets a bucket per store", () => {
|
|
8
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("prod", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("PerStore");
|
|
9
|
+
});
|
|
10
|
+
globalThis.test("'main' is production too, by the shared prod list", () => {
|
|
11
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("main", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("PerStore");
|
|
12
|
+
});
|
|
13
|
+
globalThis.test("alpha shares one bucket", () => {
|
|
14
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("alpha", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("SharedBucket");
|
|
15
|
+
});
|
|
16
|
+
globalThis.test("a PR stack shares one bucket — the factor that multiplies", () => {
|
|
17
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("pr-1234", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("SharedBucket");
|
|
18
|
+
});
|
|
19
|
+
globalThis.test("an unlisted production name falls open to the shared layout", () => {
|
|
20
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("production", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("SharedBucket");
|
|
21
|
+
});
|
|
22
|
+
globalThis.test("adding it to the prod list is the fix", () => {
|
|
23
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("production", [
|
|
24
|
+
"prod",
|
|
25
|
+
"production"
|
|
26
|
+
])).toEqual("PerStore");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
globalThis.describe("Util_StoreLayout.protectionFor", () => {
|
|
31
|
+
globalThis.test("alpha shares a bucket and is still protected", () => {
|
|
32
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.layoutFor("alpha", Util_HostUiDomain$ReventlessAws.defaultProdStacks)).toEqual("SharedBucket");
|
|
33
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("alpha", undefined)).toEqual("Protected");
|
|
34
|
+
});
|
|
35
|
+
globalThis.test("prod is protected", () => {
|
|
36
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prod", undefined)).toEqual("Protected");
|
|
37
|
+
});
|
|
38
|
+
globalThis.test("a PR stack is unprotected so teardown does not leak buckets", () => {
|
|
39
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("pr-42", undefined)).toEqual("Unprotected");
|
|
40
|
+
});
|
|
41
|
+
globalThis.test("'prepare' is not a PR stack — the prefix is 'pr-', not 'pr'", () => {
|
|
42
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.protectionFor("prepare", undefined)).toEqual("Protected");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
globalThis.describe("Util_StoreLayout.bucketNameFor", () => {
|
|
47
|
+
globalThis.test("per-store names the bucket after the declaration", () => {
|
|
48
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.bucketNameFor("PerStore", "prod", "catalog", "productImages")).toBe("catalog-productImages");
|
|
49
|
+
});
|
|
50
|
+
globalThis.test("shared names one bucket per stack", () => {
|
|
51
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.bucketNameFor("SharedBucket", "alpha", "catalog", "productImages")).toBe("alpha-stores");
|
|
52
|
+
});
|
|
53
|
+
globalThis.test("every store on a shared stack lands in the same bucket", () => {
|
|
54
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.bucketNameFor("SharedBucket", "alpha", "ordering", "invoices")).toBe(Util_StoreLayout$ReventlessAws.bucketNameFor("SharedBucket", "alpha", "catalog", "productImages"));
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
globalThis.describe("Util_StoreLayout.keyPrefixFor", () => {
|
|
59
|
+
globalThis.test("the key prefix is the store name in both layouts", () => {
|
|
60
|
+
globalThis.expect(Util_StoreLayout$ReventlessAws.keyPrefixFor("productImages")).toBe("productImages");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
let prodStacks = Util_HostUiDomain$ReventlessAws.defaultProdStacks;
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
prodStacks,
|
|
68
|
+
}
|
|
69
|
+
/* Not a pure module */
|