Skip to content

Feat/list since #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ testOverrides.rules['@typescript-eslint/no-floating-promises'] = 'off';

// Async functions are required in a few places without awaits eg `async foo() { throw Bar }`
const tsOverrides = cfg.overrides.find((ovr) => ovr.files.find((f) => f.endsWith('*.ts')));
tsOverrides.rules['@typescript-eslint/require-await'] = 'off'
tsOverrides.rules['@typescript-eslint/require-await'] = 'off';

// node23 needs "import type" when importing types
tsOverrides.rules['@typescript-eslint/consistent-type-imports'] = 'error';

module.exports = cfg;
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- uses: linz/action-typescript@dee99184c4305aea6c380a52db9b2d7abaaa3e78 # v3
with:
node-version: 20.x
node-version: 23.x

- name: Setup GIT version
id: version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
steps:
- uses: linz/action-typescript@dee99184c4305aea6c380a52db9b2d7abaaa3e78 # v3
with:
node-version: 20.x
node-version: 23.x

- name: Generate Readme
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
steps:
- uses: linz/action-typescript@dee99184c4305aea6c380a52db9b2d7abaaa3e78 # v3
with:
node-version: 20.x
node-version: 23.x

- name: Setup GIT version
id: version
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-slim@sha256:cffed8cd39d6a380434e6d08116d188c53e70611175cd5ec7700f93f32a935a6
FROM node:23-slim

RUN apt-get update && apt-get install openssh-client git -y

Expand All @@ -16,9 +16,9 @@ ENV NODE_ENV production

ADD package.json package-lock.json /app/
RUN npm install --omit=dev
ADD build/src /app/
ADD src /app/

# Cache of copy of the STAC JSON schemas by triggering a validation run
RUN node /app/index.js stac-validate https://nz-imagery.s3-ap-southeast-2.amazonaws.com/new-zealand/new-zealand_2020-2021_10m/rgb/2193/collection.json
RUN node /app/index.ts stac-validate https://nz-imagery.s3-ap-southeast-2.amazonaws.com/new-zealand/new-zealand_2020-2021_10m/rgb/2193/collection.json

ENTRYPOINT ["node", "/app/index.js"]
ENTRYPOINT ["node", "/app/index.ts"]
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@linzjs/argo-tasks",
"private": true,
"version": "4.12.0",
"version": "4.11.0",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"repository": "[email protected]:linz/argo-tasks.git",
Expand All @@ -16,23 +16,23 @@
"@linzjs/style": "^5.4.0",
"@types/node": "^20.12.10",
"@types/prettier": "^3.0.0",
"stac-ts": "^1.0.3"
"stac-ts": "^1.0.4"
},
"scripts": {
"build": "tsc",
"docs": "node build/src/readme/readme.generate.js",
"docs": "node src/readme/readme.generate.ts",
"lint": "npx eslint . --ignore-path .gitignore",
"test": "node --test build/"
"test": "node --test"
},
"publishConfig": {
"access": "restricted"
},
"type": "module",
"engines": {
"node": "^20.13.1"
"node": "^23.9.0"
},
"files": [
"build/src/**"
"src/"
],
"dependencies": {
"@aws-sdk/client-s3": "^3.440.0",
Expand Down
4 changes: 2 additions & 2 deletions src/__test__/eai_againRetry.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'node:assert';
import { beforeEach, describe, it } from 'node:test';

import { BuildHandler, MetadataBearer } from '@smithy/types';
import type { BuildHandler, MetadataBearer } from '@smithy/types';

import { eaiAgainBuilder } from '../fs.register.js';
import { eaiAgainBuilder } from '../fs.register.ts';

let callCount = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/__test__/fqdn.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';

import { FinalizeHandler, MetadataBearer } from '@smithy/types';
import type { FinalizeHandler, MetadataBearer } from '@smithy/types';

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

describe('fqdnMiddleware', () => {
const fakeNext: FinalizeHandler<object, MetadataBearer> = () => {
Expand Down
11 changes: 6 additions & 5 deletions src/__test__/fs.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { after, before, beforeEach, describe, it } from 'node:test';

import { CompositeError } from '@chunkd/core';
import { FileSystemAbstraction, fsa } from '@chunkd/fs';
import { FsAwsS3 } from '@chunkd/source-aws';
import { S3LikeV3 } from '@chunkd/source-aws-v3';
import type { FileSystemAbstraction } from '@chunkd/fs';
import { fsa } from '@chunkd/fs';
import type { FsAwsS3 } from '@chunkd/source-aws';
import type { S3LikeV3 } from '@chunkd/source-aws-v3';
import { FsMemory } from '@chunkd/source-memory';
import { InitializeMiddleware, MetadataBearer } from '@smithy/types';
import type { InitializeMiddleware, MetadataBearer } from '@smithy/types';
import assert from 'assert';

import { registerFileSystem } from '../fs.register.js';
import { registerFileSystem } from '../fs.register.ts';

export class HttpError extends Error {
statusCode: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { afterEach, it } from 'node:test';
import { TileSetType } from '@basemaps/config/build/config/tile.set.js';
import { EpsgCode } from '@basemaps/geo';
import { fsa } from '@chunkd/fs';
import { StacVersion } from 'stac-ts';
import type { StacVersion } from 'stac-ts';

import { anySlug } from '../../../utils/__test__/slugify.test.js';
import { GithubApi } from '../../../utils/github.js';
import { basemapsCreatePullRequest, ConfigType, LinzBasemapsSourceCollectionRel } from '../create-pr.js';
import { Category } from '../make.cog.github.js';
import { anySlug } from '../../../utils/__test__/slugify.test.ts';
import { GithubApi } from '../../../utils/github.ts';
import { basemapsCreatePullRequest, LinzBasemapsSourceCollectionRel } from '../create-pr.ts';

const originalEnv = Object.assign({}, process.env);

Expand Down Expand Up @@ -62,8 +61,8 @@ await it('basemapsCreatePullRequest.handler should handle S3 target', async (t)
target: targetUrlsString,
repository: 'any-owner/any-repository',
verbose: false,
category: Category.Satellite,
configType: ConfigType.Raster,
category: 'Satellite Imagery',
configType: 'raster',
individual: false,
vector: false,
ticket: 'any ticket',
Expand Down
3 changes: 2 additions & 1 deletion src/commands/basemaps-github/__test__/create-pr.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';

import { parseTargetUrl, targetInfo } from '../create-pr.js';
import type { targetInfo } from '../create-pr.ts';
import { parseTargetUrl } from '../create-pr.ts';

describe('parseTargetUrl', () => {
it('Should parse the correct target vector Urls', async () => {
Expand Down
46 changes: 22 additions & 24 deletions src/commands/basemaps-github/create-pr.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { standardizeLayerName } from '@basemaps/config';
import { ConfigLayer } from '@basemaps/config/build/config/tile.set.js';
import { Epsg, EpsgCode } from '@basemaps/geo';
import type { ConfigLayer } from '@basemaps/config/build/config/tile.set.js';
import type { EpsgCode } from '@basemaps/geo';
import { Epsg } from '@basemaps/geo';
import { fsa } from '@chunkd/fs';
import { boolean, command, flag, oneOf, option, optional, string } from 'cmd-ts';
import { StacCollection } from 'stac-ts';
import type { StacCollection } from 'stac-ts';

import { CliInfo } from '../../cli.info.js';
import { logger } from '../../log.js';
import { registerCli, verbose } from '../common.js';
import { Category, MakeCogGithub } from './make.cog.github.js';
import { CliInfo } from '../../cli.info.ts';
import { logger } from '../../log.ts';
import { registerCli, verbose } from '../common.ts';
import { Categories, MakeCogGithub } from './make.cog.github.ts';

export const ValidTargetBuckets: Set<string> = new Set(['linz-basemaps', 'linz-basemaps-staging']);
export const ValidSourceBuckets: Set<string> = new Set(['nz-imagery', 'linz-imagery', 'nz-elevation']);

export const LinzBasemapsSourceCollectionRel = 'linz_basemaps:source_collection';

export enum ConfigType {
Raster = 'raster',
Vector = 'vector',
Elevation = 'elevation',
}
export const ConfigTypes = ['raster', 'elevation', 'vector'] as const;
export type ConfigType = (typeof ConfigTypes)[number];

export function assertValidBucket(bucket: string, validBuckets: Set<string>): void {
// Validate the target information
Expand Down Expand Up @@ -202,9 +200,9 @@ export const CommandCreatePRArgs = {
description: 'New layers locations as array of strings import into basemaps-config',
}),
category: option({
type: optional(oneOf(Object.values(Category))),
type: optional(oneOf(Object.values(Categories))),
long: 'category',
description: [...Object.values(Category)].join(', '),
description: [...Object.values(Categories)].join(', '),
}),
repository: option({
type: string,
Expand All @@ -214,10 +212,10 @@ export const CommandCreatePRArgs = {
defaultValueIsSerializable: true,
}),
configType: option({
type: optional(oneOf(Object.values(ConfigType))),
type: optional(oneOf(ConfigTypes)),
long: 'config-type',
description: `Basemaps config file type, includes ${[...Object.values(ConfigType)].join(', ')}`,
defaultValue: () => ConfigType.Raster,
description: `Basemaps config file type, includes ${ConfigTypes.join(', ')}`,
defaultValue: () => 'raster' as const,
}),
individual: flag({
type: boolean,
Expand Down Expand Up @@ -246,7 +244,7 @@ export const basemapsCreatePullRequest = command({
async handler(args) {
registerCli(this, args);
const target = args.target;
const category = args.category ?? Category.Other;
const category = args.category ?? Categories.Other;
let targets: string[];
try {
targets = JSON.parse(target) as string[];
Expand All @@ -256,15 +254,15 @@ export const basemapsCreatePullRequest = command({

const layer: ConfigLayer = { name: '', title: '' };
let region;
const configType = args.vector ? ConfigType.Vector : args.configType;
if (configType === ConfigType.Vector) {
const configType = args.vector ? 'vector' : args.configType;
if (configType === 'vector') {
for (const target of targets) {
const info = await parseVectorTargetInfo(target);
layer.name = info.name;
layer.title = info.title;
layer[info.epsg] = target;
}
} else if (configType === ConfigType.Elevation) {
} else if (configType === 'elevation') {
for (const target of targets) {
const info = await parseElevationTargetInfo(target, args.individual);
layer.name = info.name;
Expand All @@ -287,11 +285,11 @@ export const basemapsCreatePullRequest = command({
if (layer.name === '' || layer.title === '') throw new Error('Failed to find the imagery name or title.');

const git = new MakeCogGithub(layer.name, args.repository, args.ticket);
if (configType === ConfigType.Vector) {
if (configType === 'vector') {
await git.updateVectorTileSet(layer.name, layer, args.individual);
} else if (configType === ConfigType.Raster) {
} else if (configType === 'raster') {
await git.updateRasterTileSet(layer.name, layer, category, args.individual, region);
} else if (configType === ConfigType.Elevation) {
} else if (configType === 'elevation') {
await git.updateElevationTileSet(layer.name, layer, args.individual, region);
} else throw new Error(`Invalid Config File target: ${configType}`);
},
Expand Down
Loading