@nyc-transit-kit/nyc-dot 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nyc-transit-kit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @nyc-transit-kit/nyc-dot
2
+
3
+ Part of `nyc-transit-kit`, an Effect-native Bun toolkit for official NYC and MTA transit data APIs.
4
+
5
+ See the repository README and docs/api-reference.md for public import paths, CLI commands, and release notes.
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@nyc-transit-kit/nyc-dot",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./bus-lanes": "./src/bus-lanes.ts",
9
+ "./client": "./src/client.ts",
10
+ "./datasets": "./src/datasets.ts",
11
+ "./errors": "./src/errors.ts",
12
+ "./traffic-speeds": "./src/traffic-speeds.ts",
13
+ "./traffic-volume": "./src/traffic-volume.ts"
14
+ },
15
+ "types": "./src/index.ts",
16
+ "files": [
17
+ "LICENSE",
18
+ "README.md",
19
+ "src"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc -b",
23
+ "test": "bun test ./test"
24
+ },
25
+ "dependencies": {
26
+ "@nyc-transit-kit/contracts": "0.1.0",
27
+ "@nyc-transit-kit/soda3": "0.1.0",
28
+ "effect": "4.0.0-beta.83"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/mannyc2/nyc-transit-kit.git",
37
+ "directory": "packages/nyc-dot"
38
+ },
39
+ "homepage": "https://github.com/mannyc2/nyc-transit-kit#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/mannyc2/nyc-transit-kit/issues"
42
+ },
43
+ "keywords": [
44
+ "bun",
45
+ "effect",
46
+ "mta",
47
+ "nyc",
48
+ "socrata",
49
+ "transit"
50
+ ],
51
+ "engines": {
52
+ "bun": ">=1.3.14"
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ import { NycDotBusLaneRow } from "@nyc-transit-kit/contracts/nyc-dot"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Schema from "effect/Schema"
4
+ import { UnsupportedDatasetError } from "./errors"
5
+
6
+ export const decodeBusLaneRow = (input: unknown) =>
7
+ Schema.decodeUnknownEffect(NycDotBusLaneRow)(input).pipe(
8
+ Effect.catchTag("SchemaError", (error) =>
9
+ Effect.fail(
10
+ UnsupportedDatasetError.make({
11
+ dataset: "bus-lanes-local-streets",
12
+ message: error.message
13
+ })
14
+ )
15
+ )
16
+ )
package/src/client.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { exportResponse } from "@nyc-transit-kit/soda3/export"
2
+ import { queryRows } from "@nyc-transit-kit/soda3/query"
3
+ import * as Effect from "effect/Effect"
4
+ import { nycDotOpenDataDomain, requireNycDotDataset } from "./datasets"
5
+
6
+ export const queryNycDotDataset = (input: {
7
+ readonly name: string
8
+ readonly query: string
9
+ readonly page?: {
10
+ readonly pageNumber: number
11
+ readonly pageSize: number
12
+ }
13
+ }) =>
14
+ Effect.gen(function* () {
15
+ const dataset = yield* requireNycDotDataset(input.name)
16
+ return yield* queryRows({
17
+ domain: nycDotOpenDataDomain,
18
+ datasetId: String(dataset.id),
19
+ query: input.query,
20
+ ...(input.page === undefined ? {} : { page: input.page })
21
+ })
22
+ })
23
+
24
+ export const exportNycDotDataset = (input: {
25
+ readonly name: string
26
+ readonly format: "csv" | "json" | "geojson"
27
+ readonly query?: string
28
+ readonly range?: {
29
+ readonly start: number
30
+ readonly end: number
31
+ }
32
+ }) =>
33
+ Effect.gen(function* () {
34
+ const dataset = yield* requireNycDotDataset(input.name)
35
+ return yield* exportResponse({
36
+ domain: nycDotOpenDataDomain,
37
+ datasetId: String(dataset.id),
38
+ format: input.format,
39
+ ...(input.query === undefined ? {} : { query: input.query }),
40
+ ...(input.range === undefined ? {} : { range: input.range })
41
+ })
42
+ })
@@ -0,0 +1,49 @@
1
+ import { makeDescriptorRegistry } from "@nyc-transit-kit/contracts/descriptor-registry"
2
+ import { NycDotDatasetDescriptor } from "@nyc-transit-kit/contracts/nyc-dot"
3
+ import * as Effect from "effect/Effect"
4
+ import * as Schema from "effect/Schema"
5
+ import { UnsupportedDatasetError } from "./errors"
6
+ import { nycDotDescriptorRecords } from "./internal/descriptor-records"
7
+
8
+ export const nycDotOpenDataDomain = "data.cityofnewyork.us"
9
+
10
+ const decodeDescriptor = Schema.decodeUnknownSync(NycDotDatasetDescriptor)
11
+ const descriptorRegistry = makeDescriptorRegistry({
12
+ descriptors: nycDotDescriptorRecords.map((record) => decodeDescriptor(record)),
13
+ id: (dataset) => String(dataset.id),
14
+ lookupKeys: (dataset) => [String(dataset.name)]
15
+ })
16
+
17
+ const requireKnownNycDotDescriptor = (name: string) => {
18
+ const descriptor = descriptorRegistry.find(name)
19
+ if (descriptor === undefined) {
20
+ throw new Error(`Missing NYC DOT descriptor: ${name}`)
21
+ }
22
+ return descriptor
23
+ }
24
+
25
+ export const busLanesLocalStreets = requireKnownNycDotDescriptor("bus-lanes-local-streets")
26
+
27
+ export const trafficSpeeds = requireKnownNycDotDescriptor("traffic-speeds")
28
+
29
+ export const trafficVolumeCounts = requireKnownNycDotDescriptor("traffic-volume-counts")
30
+
31
+ export const nycDotDatasets: ReadonlyArray<NycDotDatasetDescriptor> = descriptorRegistry.all
32
+
33
+ export const initialDatasetIds = descriptorRegistry.ids
34
+
35
+ export const findNycDotDataset = (name: string) => descriptorRegistry.find(name)
36
+
37
+ export const requireNycDotDataset = (name: string) => {
38
+ const dataset = findNycDotDataset(name)
39
+ if (dataset !== undefined) {
40
+ return Effect.succeed(dataset)
41
+ }
42
+
43
+ return Effect.fail(
44
+ UnsupportedDatasetError.make({
45
+ dataset: name,
46
+ message: `Unsupported NYC DOT dataset: ${name}`
47
+ })
48
+ )
49
+ }
package/src/errors.ts ADDED
@@ -0,0 +1,9 @@
1
+ import * as Schema from "effect/Schema"
2
+
3
+ export class UnsupportedDatasetError extends Schema.TaggedErrorClass<UnsupportedDatasetError>()(
4
+ "UnsupportedDatasetError",
5
+ {
6
+ dataset: Schema.String,
7
+ message: Schema.String
8
+ }
9
+ ) {}
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ export const packageName = "@nyc-transit-kit/nyc-dot"
2
+ export { decodeBusLaneRow } from "./bus-lanes"
3
+ export { exportNycDotDataset, queryNycDotDataset } from "./client"
4
+ export {
5
+ busLanesLocalStreets,
6
+ findNycDotDataset,
7
+ initialDatasetIds,
8
+ nycDotDatasets,
9
+ nycDotOpenDataDomain,
10
+ requireNycDotDataset,
11
+ trafficSpeeds,
12
+ trafficVolumeCounts
13
+ } from "./datasets"
14
+ export { UnsupportedDatasetError } from "./errors"
15
+ export { decodeTrafficSpeedRow } from "./traffic-speeds"
16
+ export { decodeTrafficVolumeRow } from "./traffic-volume"
@@ -0,0 +1,42 @@
1
+ import type { NycDotDatasetDescriptorInput } from "@nyc-transit-kit/contracts/nyc-dot"
2
+
3
+ export const nycDotDescriptorRecords = [
4
+ {
5
+ name: "bus-lanes-local-streets",
6
+ id: "ycrg-ses3",
7
+ title: "Bus Lanes - Local Streets",
8
+ domain: "data.cityofnewyork.us",
9
+ backing: "socrata",
10
+ description: "NYC DOT bus lane centerline dataset hosted on NYC Open Data.",
11
+ sourceUrl: "https://data.cityofnewyork.us/d/ycrg-ses3",
12
+ tags: ["transportation", "transit"],
13
+ adapterStatus: "row-schema",
14
+ lastVerified: "2026-06-16"
15
+ },
16
+ {
17
+ name: "traffic-speeds",
18
+ id: "i4gi-tjb9",
19
+ title: "DOT Traffic Speeds",
20
+ domain: "data.cityofnewyork.us",
21
+ backing: "socrata",
22
+ description: "NYC DOT realtime traffic speeds dataset hosted on NYC Open Data.",
23
+ sourceUrl: "https://data.cityofnewyork.us/d/i4gi-tjb9",
24
+ tags: ["transportation", "traffic"],
25
+ temporalFields: ["data_as_of"],
26
+ adapterStatus: "row-schema",
27
+ lastVerified: "2026-06-16"
28
+ },
29
+ {
30
+ name: "traffic-volume-counts",
31
+ id: "btm5-ppia",
32
+ title: "Traffic Volume Counts Historical",
33
+ domain: "data.cityofnewyork.us",
34
+ backing: "socrata",
35
+ description: "NYC DOT historical traffic volume counts dataset hosted on NYC Open Data.",
36
+ sourceUrl: "https://data.cityofnewyork.us/d/btm5-ppia",
37
+ tags: ["transportation", "traffic"],
38
+ temporalFields: ["count_date"],
39
+ adapterStatus: "row-schema",
40
+ lastVerified: "2026-06-16"
41
+ }
42
+ ] satisfies ReadonlyArray<NycDotDatasetDescriptorInput>
@@ -0,0 +1,16 @@
1
+ import { NycDotTrafficSpeedRow } from "@nyc-transit-kit/contracts/nyc-dot"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Schema from "effect/Schema"
4
+ import { UnsupportedDatasetError } from "./errors"
5
+
6
+ export const decodeTrafficSpeedRow = (input: unknown) =>
7
+ Schema.decodeUnknownEffect(NycDotTrafficSpeedRow)(input).pipe(
8
+ Effect.catchTag("SchemaError", (error) =>
9
+ Effect.fail(
10
+ UnsupportedDatasetError.make({
11
+ dataset: "traffic-speeds",
12
+ message: error.message
13
+ })
14
+ )
15
+ )
16
+ )
@@ -0,0 +1,16 @@
1
+ import { NycDotTrafficVolumeRow } from "@nyc-transit-kit/contracts/nyc-dot"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Schema from "effect/Schema"
4
+ import { UnsupportedDatasetError } from "./errors"
5
+
6
+ export const decodeTrafficVolumeRow = (input: unknown) =>
7
+ Schema.decodeUnknownEffect(NycDotTrafficVolumeRow)(input).pipe(
8
+ Effect.catchTag("SchemaError", (error) =>
9
+ Effect.fail(
10
+ UnsupportedDatasetError.make({
11
+ dataset: "traffic-volume-counts",
12
+ message: error.message
13
+ })
14
+ )
15
+ )
16
+ )