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
1 change: 1 addition & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"**/build",
"**/docs",
"**/.tsbuildinfo",
"contracts/**/*",
"!scratchpad/**/*",
// TODO: This should be in a nested .oxlintrc.json, but it does not work
// See related issue: https://github.com/oxc-project/oxc/issues/13204
Expand Down
1 change: 1 addition & 0 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"**/build",
"**/docs",
"**/coverage",
"contracts/**",
"!scratchpad/**/*",
// TODO: move to nested configuration if possible
"packages/amp/src/Protobuf/**"
Expand Down
33 changes: 14 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"type": "module",
"packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501",
"packageManager": "pnpm@11.1.1+sha512.d1fdf5f73c617b64fa1a56a81c3c8dfe0e966e33a6010aa256b517ae77be21d93e05affc0de1a83b0e4f29d569f68b446ae8f068cd7247c0bb3df0fb4d7bdf9a",
"scripts": {
"prepare": "effect-language-service patch",
"build": "tspc -b tsconfig.packages.json && pnpm --recursive --parallel --filter \"./packages/**/*\" run build",
Expand All @@ -15,34 +15,29 @@
"lint:fix": "oxlint --fix && dprint fmt",
"test": "vitest"
},
"pnpm": {
"overrides": {
"typescript": "^5.9.3"
}
},
"devDependencies": {
"@amp/oxc": "workspace:^",
"@babel/cli": "^7.28.6",
"@babel/core": "^7.28.6",
"@babel/core": "^7.29.0",
"@babel/plugin-transform-export-namespace-from": "^7.27.1",
"@babel/plugin-transform-modules-commonjs": "^7.28.6",
"@effect/language-service": "catalog:",
"@effect/vitest": "catalog:",
"@types/node": "^25.2.3",
"@types/node": "catalog:",
"@typescript/native-preview": "7.0.0-dev.20260130.1",
"@vitest/coverage-v8": "^4.0.18",
"@vitest/ui": "^4.0.18",
"@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:",
"babel-plugin-annotate-pure-calls": "^0.5.0",
"dprint": "^0.51.1",
"glob": "^13.0.0",
"globals": "^17.2.0",
"dprint": "^0.54.0",
"glob": "^13.0.6",
"globals": "^17.6.0",
"madge": "^8.0.0",
"oxlint": "^1.42.0",
"rulesync": "^6.7.0",
"ts-patch": "^3.3.0",
"typescript": "^5.9.3",
"vite-tsconfig-paths": "^6.0.5",
"vitest": "^4.0.18",
"oxlint": "^1.64.0",
"rulesync": "^8.17.0",
"ts-patch": "^4.0.1",
"typescript": "^6.0.3",
"vite-tsconfig-paths": "^6.1.1",
"vitest": "catalog:",
"vitest-mock-express": "^2.2.0"
}
}
12 changes: 6 additions & 6 deletions packages/amp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
"coverage": "vitest --coverage"
},
"peerDependencies": {
"@bufbuild/protobuf": "^2.11.0",
"@bufbuild/protobuf": "^2.12.0",
"@connectrpc/connect": "^2.1.1",
"@connectrpc/connect-node": "^2.1.1",
"effect": "catalog:"
},
"devDependencies": {
"@bufbuild/buf": "^1.65.0",
"@bufbuild/protobuf": "^2.11.0",
"@bufbuild/protoc-gen-es": "^2.11.0",
"@bufbuild/buf": "^1.69.0",
"@bufbuild/protobuf": "^2.12.0",
"@bufbuild/protoc-gen-es": "^2.12.0",
"@connectrpc/connect": "^2.1.1",
"@connectrpc/connect-node": "^2.1.1",
"effect": "catalog:"
},
"dependencies": {
"jiti": "^2.6.1",
"jose": "^6.1.3",
"jiti": "^2.7.0",
"jose": "^6.2.3",
"viem": "catalog:"
}
}
20 changes: 10 additions & 10 deletions packages/amp/src/admin/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ const make = Effect.fnUntraced(function*(options: MakeOptions) {
baseUrl: options.url,
transformClient: Option.match(auth, {
onNone: constUndefined,
onSome: (auth) =>
onSome: (authService) =>
HttpClient.mapRequestEffect(
Effect.fnUntraced(function*(request) {
const authInfo = yield* auth.getCachedAuthInfo.pipe(
const authInfo = yield* authService.getCachedAuthInfo.pipe(
// Treat cache errors as "no auth available"
Effect.catch(() => Effect.succeed(Option.none()))
)
Expand All @@ -285,12 +285,12 @@ const make = Effect.fnUntraced(function*(options: MakeOptions) {
// Dataset Operations

const deployDataset: Service["deployDataset"] = Effect.fn("AdminApi.deployDataset")(
function*(namespace, name, revision, options) {
function*(namespace, name, revision, deployOptions) {
const params = { namespace, name, revision }
const payload = {
endBlock: options?.endBlock,
parallelism: options?.parallelism,
workerId: options?.workerId
endBlock: deployOptions?.endBlock,
parallelism: deployOptions?.parallelism,
workerId: deployOptions?.workerId
}
yield* Effect.annotateCurrentSpan({ params, payload })
return yield* client.dataset.deployDataset({ params, payload })
Expand Down Expand Up @@ -353,11 +353,11 @@ const make = Effect.fnUntraced(function*(options: MakeOptions) {
// Job Operations

const getJobs: Service["getJobs"] = Effect.fn("AdminApi.getJobs")(
function*(options) {
function*(jobsOptions) {
const query = {
limit: options?.limit,
lastJobId: options?.lastJobId,
status: options?.status
limit: jobsOptions?.limit,
lastJobId: jobsOptions?.lastJobId,
status: jobsOptions?.status
}
yield* Effect.annotateCurrentSpan({ query })
return yield* client.job.getJobs({ query })
Expand Down
6 changes: 3 additions & 3 deletions packages/amp/src/arrow-flight/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const make = Effect.gen(function*() {
const flightDataStream = Stream.unwrap(Effect.gen(function*() {
const controller = yield* Effect.acquireRelease(
Effect.sync(() => new AbortController()),
(controller) => Effect.sync(() => controller.abort())
(abort) => Effect.sync(() => abort.abort())
)
return Stream.fromAsyncIterable(
client.doGet(ticket, { signal: controller.signal, contextValues }),
Expand Down Expand Up @@ -200,8 +200,8 @@ const make = Effect.gen(function*() {
) as any

const query = Effect.fn("ArrowFlight.query")(
function*(query: string, options?: QueryOptions) {
const chunk = yield* Stream.runCollect(streamQuery(query, options))
function*(sql: string, options?: QueryOptions) {
const chunk = yield* Stream.runCollect(streamQuery(sql, options))
return Array.from(chunk)
}
) as any
Expand Down
4 changes: 2 additions & 2 deletions packages/amp/src/auth/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ const make = Effect.gen(function*() {
429: Effect.fnUntraced(function*(response) {
const message = yield* extractErrorDescription(response)
const retryAfter = Option.fromNullishOr(response.headers["retry-after"]).pipe(
Option.flatMap((retryAfter) => {
const parsed = Number.parseInt(retryAfter, 10)
Option.flatMap((header) => {
const parsed = Number.parseInt(header, 10)
return Number.isNaN(parsed)
? Option.none()
: Option.some(Duration.seconds(parsed))
Expand Down
2 changes: 1 addition & 1 deletion packages/amp/src/internal/arrow-flight-ipc/Decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const decodeRecordBatch = (
}

// Decode children recursively
const children: ReadonlyArray<DecodedColumn> = field.children.map((field) => decodeField(field))
const children: ReadonlyArray<DecodedColumn> = field.children.map((child) => decodeField(child))

return new DecodedColumn(field, node, buffers, children)
}
Expand Down
10 changes: 5 additions & 5 deletions packages/amp/src/internal/arrow-flight-ipc/RecordBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ export const parseRecordBatchTable = Effect.fn(function*(reader: FlatBufferReade

for (let i = 0; i < nodeCount; i++) {
const nodeOffset = nodesVectorOffset + 4 + i * FIELD_NODE_SIZE
const length = reader.readInt64(nodeOffset)
const nodeLength = reader.readInt64(nodeOffset)
const nullCount = reader.readInt64(nodeOffset + 8)
nodes.push(new FieldNode(length, nullCount))
nodes.push(new FieldNode(nodeLength, nullCount))
}
}

Expand All @@ -513,9 +513,9 @@ export const parseRecordBatchTable = Effect.fn(function*(reader: FlatBufferReade

for (let i = 0; i < numBuffers; i++) {
const bufferOffset = buffersVectorOffset + 4 + i * BUFFER_SIZE
const offset = reader.readInt64(bufferOffset)
const length = reader.readInt64(bufferOffset + 8)
buffers.push(new BufferDescriptor(offset, length))
const bufferStart = reader.readInt64(bufferOffset)
const bufferLength = reader.readInt64(bufferOffset + 8)
buffers.push(new BufferDescriptor(bufferStart, bufferLength))
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/auth/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class TokenCommandError extends Data.TaggedError("TokenCommandError")<{
override readonly [Runtime.errorReported] = false
}

const audience = Flag.string("audience").pipe(
const audienceFlag = Flag.string("audience").pipe(
Flag.withAlias("a"),
Flag.withDescription(
"URLs that are valid to use the generated access token. " +
Expand All @@ -35,7 +35,7 @@ const audience = Flag.string("audience").pipe(
Flag.atLeast(0)
)

const duration = Argument.string("duration").pipe(
const durationArg = Argument.string("duration").pipe(
Argument.withDescription(
"Duration of the generated access token before it expires. " +
"Ex: \"7 days\", \"30 days\", \"1 hour\""
Expand Down Expand Up @@ -106,7 +106,7 @@ const handleTokenCommand = Effect.fnUntraced(function*({ audience, duration }: {
yield* Console.error(message)
}, Effect.catchTag("AuthCacheError", (cause) => Effect.fail(new TokenCommandError({ cause }))))

export const TokenCommand = Command.make("token", { audience, duration }).pipe(
export const TokenCommand = Command.make("token", { audience: audienceFlag, duration: durationArg }).pipe(
Command.withDescription(
"Generates an access token (Bearer JWT) to be used by your applictaion to interact with Amp"
),
Expand Down
31 changes: 18 additions & 13 deletions packages/cli/src/commands/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ export class QueryCommandError extends Data.TaggedError("QueryCommandError")<{
}

// TODO(Chris): we should re-evaluate this format option
const format = Flag.choice("format", ResultFormats).pipe(
const formatFlag = Flag.choice("format", ResultFormats).pipe(
Flag.withAlias("f"),
Flag.withDescription("The format to output the results in."),
Flag.withDefault("table")
)

const limit = Flag.integer("limit").pipe(
const limitFlag = Flag.integer("limit").pipe(
Flag.withDescription("The number of rows to return from the query."),
Flag.optional
)

const query = Argument.string("query").pipe(
const queryArg = Argument.string("query").pipe(
Argument.withDescription("The SQL query to execute.")
)

const token = Flag.redacted("token").pipe(
const tokenFlag = Flag.redacted("token").pipe(
Flag.withAlias("t"),
Flag.withDescription("The bearer token to use for authentication."),
Flag.optional
Expand All @@ -51,40 +51,45 @@ const queryCommandHandler = Effect.fnUntraced(function*(params: {
}) {
const flight = yield* ArrowFlight.ArrowFlight

const query = Option.match(params.limit, {
const sql = Option.match(params.limit, {
onNone: () => params.query,
onSome: (limit) => `${params.query} LIMIT ${limit}`
})

const results = yield* flight.query(query)
const results = yield* flight.query(sql)

const data = results
const rows = results
.filter(({ data }) => data.length > 0)
.flatMap(({ data }) => data)

switch (params.format) {
case "json": {
return yield* Console.log(JSON.stringify(data, null, 2))
return yield* Console.log(JSON.stringify(rows, null, 2))
}
case "jsonl": {
return yield* Console.log(JSON.stringify(data))
return yield* Console.log(JSON.stringify(rows))
}
case "pretty": {
return yield* Console.log(data)
return yield* Console.log(rows)
}
case "table": {
return yield* Console.table(data)
return yield* Console.table(rows)
}
}
}, Effect.mapError((cause) => new QueryCommandError({ cause })))

export const QueryCommand = Command.make("query", { format, limit, query, token }).pipe(
export const QueryCommand = Command.make("query", {
format: formatFlag,
limit: limitFlag,
query: queryArg,
token: tokenFlag
}).pipe(
Command.withDescription("Execute a SQL query with Amp"),
Command.withHandler(queryCommandHandler),
Command.provide(({ token }) => {
const layerInterceptorAuth = Option
.match(token, {
onSome: (token) => ArrowFlight.layerInterceptorToken(token),
onSome: (bearer) => ArrowFlight.layerInterceptorToken(bearer),
onNone: () => ArrowFlight.layerInterceptorBearerAuth
})
return ArrowFlight.layer.pipe(
Expand Down
1 change: 1 addition & 0 deletions packages/tools/oxc/oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// Code quality
"eslint/no-console": "error",
"eslint/no-var": "error",
"eslint/no-underscore-dangle": "allow",
"eslint/no-useless-constructor": "error",
"unicorn/no-abusive-eslint-disable": "error",
"eslint/no-unneeded-ternary": "error",
Expand Down
4 changes: 2 additions & 2 deletions packages/tools/oxc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"coverage": "vitest --coverage"
},
"devDependencies": {
"@types/node": "^25.1.0",
"vitest": "^4.0.18"
"@types/node": "catalog:",
"vitest": "catalog:"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "node:fs"
import * as path from "node:path"
import type { CreateRule, ESTree, Visitor } from "oxlint"
import type { CreateRule, ESTree, Visitor } from "../types.ts"

interface RuleOptions {
checkPatterns?: Array<string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CreateRule, ESTree, Fixer, Visitor } from "oxlint"
import type { CreateRule, ESTree, Fixer, Visitor } from "../types.ts"

const jsExtensions = [".js", ".jsx", ".mjs", ".cjs"]
const extensionMap: Record<string, string> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CreateRule, ESTree, Visitor } from "oxlint"
import type { CreateRule, ESTree, Visitor } from "../types.ts"

const SCHEMA_SOURCES = new Set(["effect", "effect/Schema"])
const SCHEMA_NAMESPACE_SOURCES = new Set(["effect/Schema"])
Expand Down
Loading
Loading