Skip to content

Commit d50ffb7

Browse files
ShadowCat567Vieltojarvigithub-advanced-security[bot]
authored
Resolve storage output typing issues (#2696)
* created config v4 * update to 1.4 * add test and change zod schema * changeset * added storage section to custom outputs * zod schema update * updated storage test * Potential fix for code scanning alert no. 339: Incorrect suffix check Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * added section to custom outputs storage * moved jsonschema to dev deps * jsonschema dep * update to paths finding * update backwards compatibility test * updated messaging * hopefully fix outputs compatibility test * final PR feedback --------- Co-authored-by: Vieltojarvi <[email protected]> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 8899e06 commit d50ffb7

36 files changed

+1382
-125
lines changed

.changeset/all-mugs-stop.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@aws-amplify/integration-tests': patch
3+
'@aws-amplify/backend': patch
4+
'@aws-amplify/seed': patch
5+
'@aws-amplify/backend-cli': patch
6+
---
7+
8+
updated tests and changed client config to v1.4

.changeset/polite-cases-move.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@aws-amplify/backend-output-schemas': minor
3+
'@aws-amplify/client-config': minor
4+
---
5+
6+
client config v1.4 and loosen zod typing for storage

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend-output-schemas/src/storage/v1.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ const storageAccessActionEnum = z.enum([
1010

1111
const pathSchema = z.record(
1212
z.string(),
13-
z.object({
14-
guest: z.array(storageAccessActionEnum).optional(),
15-
authenticated: z.array(storageAccessActionEnum).optional(),
16-
groups: z.array(storageAccessActionEnum).optional(),
17-
entity: z.array(storageAccessActionEnum).optional(),
18-
resource: z.array(storageAccessActionEnum).optional(),
19-
}),
13+
z.intersection(
14+
z.object({
15+
guest: z.array(storageAccessActionEnum),
16+
authenticated: z.array(storageAccessActionEnum),
17+
resource: z.array(storageAccessActionEnum),
18+
}),
19+
z.record(z.string(), z.array(storageAccessActionEnum)),
20+
),
2021
);
2122

2223
const bucketSchema = z.object({

packages/backend/src/backend_factory.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void describe('Backend', () => {
196196
const backend = new BackendFactory({}, rootStack);
197197
const clientConfigPartial: DeepPartialAmplifyGeneratedConfigs<ClientConfig> =
198198
{
199-
version: '1.3',
199+
version: '1.4',
200200
custom: {
201201
someCustomOutput: 'someCustomOutputValue',
202202
},

packages/backend/src/backend_factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const rootStackTypeIdentifier = 'root';
3333

3434
// Client config version that is used by `backend.addOutput()`
3535
const DEFAULT_CLIENT_CONFIG_VERSION_FOR_BACKEND_ADD_OUTPUT =
36-
ClientConfigVersionOption.V1_3;
36+
ClientConfigVersionOption.V1_4;
3737

3838
/**
3939
* Factory that collects and instantiates all the Amplify backend constructs

packages/backend/src/engine/custom_outputs_accumulator.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ void describe('Custom outputs accumulator', () => {
5959
);
6060

6161
const configPart1: DeepPartialAmplifyGeneratedConfigs<ClientConfig> = {
62-
version: '1.3',
62+
version: '1.4',
6363
custom: { output1: 'val1' },
6464
};
6565
const configPart2: DeepPartialAmplifyGeneratedConfigs<ClientConfig> = {
66-
version: '1.3',
66+
version: '1.4',
6767
custom: { output2: 'val2' },
6868
};
6969
accumulator.addOutput(configPart1);
@@ -115,7 +115,7 @@ void describe('Custom outputs accumulator', () => {
115115

116116
assert.throws(
117117
() =>
118-
accumulator.addOutput({ version: '1.3', custom: { output1: 'val1' } }),
118+
accumulator.addOutput({ version: '1.4', custom: { output1: 'val1' } }),
119119
(error: AmplifyUserError) => {
120120
assert.strictEqual(
121121
error.message,

packages/cli/src/commands/generate/outputs/generate_outputs_command.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void describe('generate outputs command', () => {
7474
assert.equal(generateClientConfigMock.mock.callCount(), 1);
7575
assert.deepEqual(
7676
generateClientConfigMock.mock.calls[0].arguments[1],
77-
'1.3', // default version
77+
'1.4', // default version
7878
);
7979
assert.deepEqual(
8080
generateClientConfigMock.mock.calls[0].arguments[2],
@@ -95,7 +95,7 @@ void describe('generate outputs command', () => {
9595
namespace: 'app_id',
9696
type: 'branch',
9797
},
98-
'1.3',
98+
'1.4',
9999
'/foo/bar',
100100
undefined,
101101
],
@@ -113,7 +113,7 @@ void describe('generate outputs command', () => {
113113
{
114114
stackName: 'stack_name',
115115
},
116-
'1.3',
116+
'1.4',
117117
'/foo/bar',
118118
undefined,
119119
],
@@ -131,7 +131,7 @@ void describe('generate outputs command', () => {
131131
{
132132
stackName: 'stack_name',
133133
},
134-
'1.3',
134+
'1.4',
135135
'foo/bar',
136136
undefined,
137137
],
@@ -149,7 +149,7 @@ void describe('generate outputs command', () => {
149149
{
150150
stackName: 'stack_name',
151151
},
152-
'1.3',
152+
'1.4',
153153
'foo/bar',
154154
ClientConfigFormat.DART,
155155
],

packages/cli/src/commands/sandbox/sandbox_command.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ void describe('sandbox command', () => {
328328
);
329329
});
330330

331-
void it('sandbox creates an empty client config file if one does not already exist for version 1.3', async (contextual) => {
331+
void it('sandbox creates an empty client config file if one does not already exist for version 1.4', async (contextual) => {
332332
contextual.mock.method(fs, 'existsSync', () => false);
333333
const writeFileMock = contextual.mock.method(fsp, 'writeFile', () => true);
334-
await commandRunner.runCommand('sandbox --outputs-version 1.3');
334+
await commandRunner.runCommand('sandbox --outputs-version 1.4');
335335
assert.equal(sandboxStartMock.mock.callCount(), 1);
336336
assert.equal(writeFileMock.mock.callCount(), 1);
337337
assert.deepStrictEqual(
338338
writeFileMock.mock.calls[0].arguments[1],
339-
`{\n "version": "1.3"\n}`,
339+
`{\n "version": "1.4"\n}`,
340340
);
341341
assert.deepStrictEqual(
342342
writeFileMock.mock.calls[0].arguments[0],

packages/cli/src/commands/sandbox/sandbox_event_handler_factory.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void describe('sandbox_event_handler_factory', () => {
2424
} as unknown as ClientConfigGeneratorAdapter;
2525
const clientConfigLifecycleHandler = new ClientConfigLifecycleHandler(
2626
clientConfigGeneratorAdapterMock,
27-
'1.3',
27+
'1.4',
2828
'test-out',
2929
ClientConfigFormat.JSON,
3030
);
@@ -80,7 +80,7 @@ void describe('sandbox_event_handler_factory', () => {
8080
namespace: 'test',
8181
name: 'name',
8282
},
83-
'1.3',
83+
'1.4',
8484
'test-out',
8585
'json',
8686
]);
@@ -192,7 +192,7 @@ void describe('sandbox_event_handler_factory', () => {
192192
namespace: 'test',
193193
name: 'name',
194194
},
195-
'1.3',
195+
'1.4',
196196
'test-out',
197197
'json',
198198
]);

0 commit comments

Comments
 (0)