Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
683 changes: 144 additions & 539 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"@chunkd/source-memory": "^10.1.0",
"@linzjs/style": "^5.1.0",
"@linzjs/style": "^5.2.0",
"@types/node": "^20.12.10",
"@types/prettier": "^3.0.0",
"stac-ts": "^1.0.0"
Expand Down
10 changes: 5 additions & 5 deletions src/__test__/eai_againRetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ function fakeNextBuilder(failCount: number): BuildHandler<object, MetadataBearer
return fakeNext;
}

describe('eai_againRetryMiddleware', () => {
void describe('eai_againRetryMiddleware', () => {
beforeEach(() => {
callCount = 0;
});
it('should run next once if it succeeds', () => {
void it('should run next once if it succeeds', () => {
const fakeNext = fakeNextBuilder(0);
eaiAgainBuilder(() => 0)(fakeNext, {})({ input: {}, request: {} });
assert.equal(callCount, 1);
});

it('should try three times when getting EAI_AGAIN errors', async () => {
void it('should try three times when getting EAI_AGAIN errors', async () => {
const fakeNext = fakeNextBuilder(2);
await eaiAgainBuilder(() => 0)(fakeNext, {})({ input: {}, request: {} });
assert.equal(callCount, 3);
});

it('should throw error if fails with unknown error type', () => {
void it('should throw error if fails with unknown error type', () => {
const fakeNext: BuildHandler<object, MetadataBearer> = () => {
return Promise.reject({ message: 'ERROR MESSAGE' });
};
Expand All @@ -45,7 +45,7 @@ describe('eai_againRetryMiddleware', () => {
});
});

it('should throw error if next fails with EAI_AGAIN three times', () => {
void it('should throw error if next fails with EAI_AGAIN three times', () => {
const fakeNext = fakeNextBuilder(3);
assert.rejects(eaiAgainBuilder(() => 0)(fakeNext, {})({ input: {}, request: {} }), {
message: 'EAI_AGAIN maximum tries (3) exceeded',
Expand Down
10 changes: 5 additions & 5 deletions src/__test__/fqdn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ import { FinalizeHandler, MetadataBearer } from '@smithy/types';

import { fqdn } from '../fs.register.js';

describe('fqdnMiddleware', () => {
void describe('fqdnMiddleware', () => {
const fakeNext: FinalizeHandler<object, MetadataBearer> = () => {
return Promise.resolve({ output: { $metadata: {} }, response: {} });
};
const fakeRequest = { input: {}, request: { hostname: 'nz-imagery.s3.ap-southeast-2.amazonaws.com' } };

it('should add FQDN to s3 requests', () => {
void it('should add FQDN to s3 requests', () => {
fakeRequest.request.hostname = 'nz-imagery.s3.ap-southeast-2.amazonaws.com';
fqdn(fakeNext, {})(fakeRequest);
assert.equal(fakeRequest.request.hostname, 'nz-imagery.s3.ap-southeast-2.amazonaws.com.');
});

it('should not add for other services', () => {
void it('should not add for other services', () => {
fakeRequest.request.hostname = 'logs.ap-southeast-2.amazonaws.com';
fqdn(fakeNext, {})(fakeRequest);
assert.equal(fakeRequest.request.hostname, 'logs.ap-southeast-2.amazonaws.com');
});

it('should not add for other regions', () => {
void it('should not add for other regions', () => {
fakeRequest.request.hostname = 'nz-imagery.s3.us-east-1.amazonaws.com';
fqdn(fakeNext, {})(fakeRequest);
assert.equal(fakeRequest.request.hostname, 'nz-imagery.s3.us-east-1.amazonaws.com');
});

it('should not add for unknown hosts', () => {
void it('should not add for unknown hosts', () => {
fakeRequest.request.hostname = 'google.com';
fqdn(fakeNext, {})(fakeRequest);
assert.equal(fakeRequest.request.hostname, 'google.com');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FeatureCollection } from 'geojson';

import { createMapSheet } from '../create-mapsheet.js';

describe('copyFiles', () => {
void describe('copyFiles', () => {
const rest: FeatureCollection = {
type: 'FeatureCollection',
features: [
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('copyFiles', () => {
mem.put(satellite);
mem.put(southland);

it('Should create the correct map sheets', async () => {
void it('Should create the correct map sheets', async () => {
const outputs = await createMapSheet(aerial, mem, rest, undefined, undefined);

assert.deepEqual(outputs, [
Expand All @@ -137,7 +137,7 @@ describe('copyFiles', () => {
]);
});

it('Should exclude the satellite', async () => {
void it('Should exclude the satellite', async () => {
const outputs = await createMapSheet(aerial, mem, rest, undefined, new RegExp('satellite', 'i'));

assert.deepEqual(outputs, [
Expand Down
8 changes: 4 additions & 4 deletions src/commands/copy/__test__/copy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { FsMemory } from '@chunkd/source-memory';

import { worker } from '../copy-worker.js';

describe('copyFiles', () => {
void describe('copyFiles', () => {
const memory = new FsMemory();
fsa.register('memory://', memory);

beforeEach(() => {
memory.files.clear();
});

it('should copy to the target location', async () => {
void it('should copy to the target location', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true })), {
contentType: 'application/json',
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('copyFiles', () => {
assert.equal(String(memory.files.get('memory://target/topographic.png')?.buffer), 'test');
});

it('should default to COG/json', async () => {
void it('should default to COG/json', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true })), {
contentType: 'application/octet-stream',
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('copyFiles', () => {
assert.equal(tiffTarget?.contentType, 'image/tiff; application=geotiff; profile=cloud-optimized');
});

it('should not default COG/json when fixContentType=false', async () => {
void it('should not default COG/json when fixContentType=false', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true })), {
contentType: 'application/octet-stream',
Expand Down
14 changes: 7 additions & 7 deletions src/commands/create-manifest/__test__/create-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { FsMemory } from '@chunkd/source-memory';

import { createManifest, validatePaths } from '../create-manifest.js';

describe('createManifest', () => {
void describe('createManifest', () => {
beforeEach(() => {
memory.files.clear();
});
const memory = new FsMemory();
fsa.register('memory://', memory);
it('should copy to the target location', async () => {
void it('should copy to the target location', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true }))),
fsa.write('memory://source/foo/bar/topographic.png', Buffer.from('test')),
Expand All @@ -31,7 +31,7 @@ describe('createManifest', () => {
]);
});

it('should transform files', async () => {
void it('should transform files', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true }))),
fsa.write('memory://source/foo/bar/topographic.png', Buffer.from('test')),
Expand All @@ -52,7 +52,7 @@ describe('createManifest', () => {
]);
});

it('should copy to the target location without flattening', async () => {
void it('should copy to the target location without flattening', async () => {
await Promise.all([
fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true }))),
fsa.write('memory://source/foo/bar/topographic.png', Buffer.from('test')),
Expand All @@ -71,7 +71,7 @@ describe('createManifest', () => {
]);
});

it('should copy single file to the target location without a trailing /', async () => {
void it('should copy single file to the target location without a trailing /', async () => {
await Promise.all([fsa.write('memory://source/topographic.json', Buffer.from(JSON.stringify({ test: true })))]);

const outputFiles = await createManifest(
Expand All @@ -87,12 +87,12 @@ describe('createManifest', () => {
]);
});
describe('validatePaths', () => {
it('Should throw error for mismatched paths', () => {
void it('Should throw error for mismatched paths', () => {
assert.throws(() => {
validatePaths('memory://source/', 'memory://target/sub/test.tiff');
}, Error);
});
it('Should also throw error for mismatched paths', () => {
void it('Should also throw error for mismatched paths', () => {
assert.throws(() => {
validatePaths('memory://source/test.tiff', 'memory://target/sub/');
}, Error);
Expand Down
18 changes: 9 additions & 9 deletions src/commands/group/__test__/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { FsMemory } from '@chunkd/source-memory';

import { commandGroup, groupItems } from '../group.js';

describe('groupItems', () => {
it('should group items', () => {
void describe('groupItems', () => {
void it('should group items', () => {
assert.deepEqual(groupItems([1, 2, 3, 4], 2), [
[1, 2],
[3, 4],
Expand All @@ -16,23 +16,23 @@ describe('groupItems', () => {
assert.deepEqual(groupItems([1, 2, 3, 4], 3), [[1, 2, 3], [4]]);
});

it('should group max', () => {
void it('should group max', () => {
assert.deepEqual(groupItems([1, 2, 3, 4], 100), [[1, 2, 3, 4]]);
});

it('should group min', () => {
void it('should group min', () => {
assert.deepEqual(groupItems([1, 2, 3, 4], 1), [[1], [2], [3], [4]]);
});
});

describe('group', () => {
void describe('group', () => {
const memoryFs = new FsMemory();

before(() => {
fsa.register('/tmp/group', memoryFs);
});

it('should load from a JSON array', async () => {
void it('should load from a JSON array', async () => {
await commandGroup.handler({ inputs: [JSON.stringify([1, 2, 3, 4])], forceOutput: true, size: 50, ...values });
assert.deepEqual(await fsa.readJson('/tmp/group/output.json'), ['000']);
assert.deepEqual(await fsa.readJson('/tmp/group/output/000.json'), [1, 2, 3, 4]);
Expand All @@ -44,7 +44,7 @@ describe('group', () => {
fromFile: undefined,
};

it('should load from multiple JSON arrays', async () => {
void it('should load from multiple JSON arrays', async () => {
await commandGroup.handler({
inputs: [JSON.stringify([1, 2, 3, 4]), JSON.stringify(['alpha'])],
forceOutput: true,
Expand All @@ -57,7 +57,7 @@ describe('group', () => {
assert.deepEqual(await fsa.readJson('/tmp/group/output/001.json'), [4, 'alpha']);
});

it('should load from strings', async () => {
void it('should load from strings', async () => {
await commandGroup.handler({
inputs: ['s3://foo/bar', JSON.stringify([1, 2, 3, 4]), JSON.stringify(['alpha'])],
forceOutput: true,
Expand All @@ -69,7 +69,7 @@ describe('group', () => {
assert.deepEqual(await fsa.readJson('/tmp/group/output/001.json'), [3, 4, 'alpha']);
});

it('should load from a file', async () => {
void it('should load from a file', async () => {
await fsa.write('/tmp/group/input.json', Buffer.from(JSON.stringify([1, 2, 3, 4, 5])));
await commandGroup.handler({
inputs: [],
Expand Down
Loading