Skip to content

Commit fa18b39

Browse files
committed
fix formatting issues
1 parent 2f945b0 commit fa18b39

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

contrib/external-storage-s3-aws-sdk/src/__tests__/test-aws-sdk-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ test('objectExists returns true when the head succeeds', async (t) => {
3535

3636
test('getObject reads the response body as bytes', async (t) => {
3737
const bytes = new Uint8Array([1, 2, 3]);
38-
const client = new AwsSdkS3StorageDriverClient(fakeS3Client(() => Promise.resolve({ Body: { transformToByteArray: async () => bytes } })));
38+
const client = new AwsSdkS3StorageDriverClient(
39+
fakeS3Client(() => Promise.resolve({ Body: { transformToByteArray: async () => bytes } }))
40+
);
3941
t.deepEqual(await client.getObject('b', 'k'), bytes);
4042
});
4143

contrib/external-storage-s3-aws-sdk/src/aws-sdk-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class AwsSdkS3StorageDriverClient implements S3StorageDriverClient {
2020

2121
async objectExists(bucket: string, key: string, options?: S3RequestOptions): Promise<boolean> {
2222
try {
23-
await this.client.send(new HeadObjectCommand({ Bucket: bucket, Key: key }), { abortSignal: options?.abortSignal });
23+
await this.client.send(new HeadObjectCommand({ Bucket: bucket, Key: key }), {
24+
abortSignal: options?.abortSignal,
25+
});
2426
return true;
2527
} catch (err) {
2628
if (isNotFound(err)) {

contrib/external-storage-s3/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ const myClient: S3StorageDriverClient = {
4848
},
4949
};
5050
```
51+
5152
## Dynamic bucket selection
5253

5354
Pass a callable as `bucket` to choose the destination per payload:
5455

5556
```ts
5657
const driver = new S3StorageDriver({
5758
client: new AwsSdkS3StorageDriverClient(s3Client),
58-
bucket: (_context, payload) =>
59-
(payload.data?.length ?? 0) > 10 * 1024 * 1024 ? 'large-payloads' : 'small-payloads',
59+
bucket: (_context, payload) => ((payload.data?.length ?? 0) > 10 * 1024 * 1024 ? 'large-payloads' : 'small-payloads'),
6060
});
6161
```
6262

@@ -81,16 +81,19 @@ All Temporal S3 drivers generate S3 keys in a consistent manner.
8181
### Key format
8282

8383
Workflow key:
84+
8485
```text
8586
v0/ns/{namespace}/wt/{workflow-type}/wi/{workflow-id}/ri/{run-id}/d/{hash-algorithm}/{hex-digest}
8687
```
8788

8889
Activity key:
90+
8991
```text
9092
v0/ns/{namespace}/at/{activity-type}/ai/{activity-id}/ri/{run-id}/d/{hash-algorithm}/{hex-digest}
9193
```
9294

9395
Fallback key (unknown target):
96+
9497
```text
9598
v0/d/{hash-algorithm}/{hex-digest}
9699
```
@@ -105,13 +108,14 @@ v0/d/{hash-algorithm}/{hex-digest}
105108
The Temporal SDKs escape anything that isn't listed in S3's safe character set: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
106109

107110
Safe Characters:
111+
108112
```text
109-
Alphanumeric characters
113+
Alphanumeric characters
110114
0-9
111115
a-z
112116
A-Z
113117
114-
Special characters
118+
Special characters
115119
Exclamation point (!)
116120
Hyphen (-)
117121
Underscore (_)
@@ -152,4 +156,4 @@ input:
152156
153157
output:
154158
v0/ns/payments%20prod/at/Capture%2FCharge/ai/activity%20id%2B42/ri/9e1d1fd9-2f8a-4c40-93e2-731f31b9268b/d/sha256/2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
155-
```
159+
```

contrib/external-storage-s3/src/__tests__/test-driver.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ test('key is content-addressed and segmented by the store context', async (t) =>
6262

6363
const [claim] = await driver.store(workflowContext, [makePayload('"hello"')]);
6464

65-
t.regex(
66-
claim!.claimData.key!,
67-
/^v0\/ns\/my-ns\/wt\/MyWorkflow\/wi\/wf-1\/ri\/run-1\/d\/sha256\/[0-9a-f]{64}$/
68-
);
65+
t.regex(claim!.claimData.key!, /^v0\/ns\/my-ns\/wt\/MyWorkflow\/wi\/wf-1\/ri\/run-1\/d\/sha256\/[0-9a-f]{64}$/);
6966
t.is(claim!.claimData.hashAlgorithm, 'sha256');
7067
t.is(claim!.claimData.bucket, 'b');
7168
});

contrib/external-storage-s3/src/driver.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class S3StorageDriver implements StorageDriver {
129129
throw new ValueError(`maxPayloadSize must be a positive finite number, got ${String(maxPayloadSize)}`);
130130
}
131131
this.client = client;
132-
this.bucket = (typeof bucket === 'string') ? () => bucket : bucket;
132+
this.bucket = typeof bucket === 'string' ? () => bucket : bucket;
133133
this.name = driverName || DRIVER_TYPE;
134134
this.maxPayloadSize = maxPayloadSize;
135135
}
@@ -142,9 +142,7 @@ export class S3StorageDriver implements StorageDriver {
142142
}
143143

144144
async retrieve(context: StorageDriverRetrieveContext, claims: StorageDriverClaim[]): Promise<Payload[]> {
145-
return gatherWithCancellation(context.abortSignal, (signal) =>
146-
claims.map((claim) => this.download(claim, signal))
147-
);
145+
return gatherWithCancellation(context.abortSignal, (signal) => claims.map((claim) => this.download(claim, signal)));
148146
}
149147

150148
private async upload(
@@ -183,8 +181,7 @@ export class S3StorageDriver implements StorageDriver {
183181
const { bucket, key, hashAlgorithm, hashValue: expectedHash } = claim.claimData;
184182
if (!bucket || !key) {
185183
throw new ValueError(
186-
`S3StorageDriver claim is missing required location information: ` +
187-
`claimData must contain 'bucket' and 'key'`
184+
`S3StorageDriver claim is missing required location information: ` + `claimData must contain 'bucket' and 'key'`
188185
);
189186
}
190187
if (!hashAlgorithm || !expectedHash) {

0 commit comments

Comments
 (0)