Skip to content
Merged
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
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
workflow_dispatch:
inputs:
semver:
description: "The semver to use"
required: true
default: "auto"
type: choice
options:
- auto
- patch
- minor
- major
- prerelease
- prepatch
- preminor
- premajor
pull_request:
types: [closed]

jobs:
release:
if: >-
${{
(
startsWith(github.event.inputs.semver, 'pre') ||
github.ref == format(
'refs/heads/{0}',
github.event.repository.default_branch
)
) &&
(
github.event_name != 'pull_request' ||
github.event.pull_request.user.login == 'optic-release-automation[bot]'
)
}}
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: nearform-actions/optic-release-automation-action@9e3518763346efacba15d729d0faaa4cbd8fdd52 # v4.12.3
with:
commit-message: "Release {version}"
sync-semver-tags: false
access: "public"
# This prefix is added before the prerelease number, e.g. `v3.0.0-pre.0`
prerelease-prefix: "pre"
semver: ${{ github.event.inputs.semver }}
# Prereleases are published under the `next` npm dist-tag
npm-tag: ${{ startsWith(github.event.inputs.semver, 'pre') && 'next' || 'latest' }}
# Don't notify linked issues
notify-linked-issues: false
publish-mode: oidc
build-command: |
npm ci
80 changes: 78 additions & 2 deletions package-lock.json

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

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@comapeo/map-server",
"version": "1.0.0",
"version": "1.0.0-pre.0",
"type": "module",
"exports": {
".": {
Expand All @@ -13,10 +13,11 @@
"test:js": "vitest run",
"test:lint": "eslint",
"test:types": "tsc --noEmit",
"test:publint": "npm run build && publint",
"format": "prettier --write .",
"prepare": "husky",
"prepack": "tsc -p tsconfig.npm.json",
"postinstall": "patch-package"
"prepare": "husky && patch-package",
Comment thread
achou11 marked this conversation as resolved.
"build": "tsc -p tsconfig.npm.json",
"prepack": "run-s test build"
},
"keywords": [],
"author": "",
Expand All @@ -40,6 +41,7 @@
"npm-run-all2": "^7.0.2",
"patch-package": "^8.0.1",
"prettier": "^3.7.4",
"publint": "^0.3.17",
"type-fest": "^5.3.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.53.1",
Expand Down
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ import { fetchAPI } from './lib/fetch-api.js'
import { RootRouter } from './routes/root.js'
import type { FetchContext } from './types.js'

export { errors } from './lib/errors.js'

export type {
MapInfo,
MapShareState,
MapShareStateUpdate,
DownloadStateUpdate,
} from './types.js'
export type { DownloadState } from './lib/download-request.js'
export type {
MapShareCreateParams,
MapShareDeclineParams,
} from './routes/map-shares.js'
export type { DownloadCreateParams } from './routes/downloads.js'

export type ServerOptions = {
defaultOnlineStyleUrl: string | URL
customMapPath: string | URL
Expand Down
10 changes: 5 additions & 5 deletions src/lib/download-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { Agent as SecretStreamAgent } from 'secret-stream-http'
import z32 from 'z32'

import { TypedEventTarget } from '../lib/event-target.js'
import type { DownloadCreateRequest } from '../routes/downloads.js'
import type { DownloadCreateParams } from '../routes/downloads.js'
import { type DownloadStateUpdate } from '../types.js'
import { StatusError } from './errors.js'
import { errors, jsonError } from './errors.js'
import { secretStreamFetch } from './secret-stream-fetch.js'
import { StateUpdateEvent } from './state-update-event.js'
import { addTrailingSlash, generateId, getErrorCode, noop } from './utils.js'

type DownloadRequestState = DownloadStateUpdate &
Omit<DownloadCreateRequest, 'mapShareUrls'> & { downloadId: string }
export type DownloadState = DownloadStateUpdate &
Omit<DownloadCreateParams, 'mapShareUrls'> & { downloadId: string }

export class DownloadRequest extends TypedEventTarget<
InstanceType<typeof StateUpdateEvent<DownloadStateUpdate>>
> {
#state: DownloadRequestState
#state: DownloadState
#abortController = new AbortController()
#transform = new TransformStream({
transform: (chunk, controller) => {
Expand All @@ -34,7 +34,7 @@ export class DownloadRequest extends TypedEventTarget<

constructor(
stream: WritableStream<Uint8Array>,
{ mapShareUrls, ...rest }: DownloadCreateRequest,
{ mapShareUrls, ...rest }: DownloadCreateParams,
keyPair: { publicKey: Uint8Array; secretKey: Uint8Array },
) {
super()
Expand Down
2 changes: 1 addition & 1 deletion src/routes/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DownloadCreateRequest = T.Object({
estimatedSizeBytes: EstimatedSizeBytes,
})

export type DownloadCreateRequest = Static<typeof DownloadCreateRequest>
export type DownloadCreateParams = Static<typeof DownloadCreateRequest>

export function DownloadsRouter(
{ base }: { base: string },
Expand Down
4 changes: 4 additions & 0 deletions src/routes/map-shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const MapShareCreateRequest = T.Object({
receiverDeviceId: T.String({ minLength: 1 }),
})

export type MapShareCreateParams = Static<typeof MapShareCreateRequest>

const LocalMapShareDeclineRequest = T.Object({
reason: MapShareDeclineReason,
mapShareUrls: MapShareUrls,
Expand All @@ -39,6 +41,8 @@ const LocalMapShareDeclineRequest = T.Object({
}),
})

export type MapShareDeclineParams = Static<typeof LocalMapShareDeclineRequest>

const RemoteMapShareDeclineRequest = T.Object({
reason: MapShareDeclineReason,
})
Expand Down