New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kysely-s3-select

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-s3-select - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

5

./dist/cjs/index.js

@@ -112,3 +112,4 @@ "use strict";

if (Records) {
stringifiedOutputs.push(textDecoder.decode(Records.Payload));
const decodedText = textDecoder.decode(Records.Payload);
stringifiedOutputs.push(decodedText);
}

@@ -138,3 +139,3 @@ }

QuoteEscapeCharacter: csvOptions?.quoteEscapeCharacter || '"',
RecordDelimiter: csvOptions?.recordDelimiter
RecordDelimiter: csvOptions?.recordDelimiter || "\n"
}

@@ -141,0 +142,0 @@ };

@@ -112,3 +112,4 @@ "use strict";

if (Records) {
stringifiedOutputs.push(textDecoder.decode(Records.Payload));
const decodedText = textDecoder.decode(Records.Payload);
stringifiedOutputs.push(decodedText);
}

@@ -138,3 +139,3 @@ }

QuoteEscapeCharacter: csvOptions?.quoteEscapeCharacter || '"',
RecordDelimiter: csvOptions?.recordDelimiter
RecordDelimiter: csvOptions?.recordDelimiter || "\n"
}

@@ -141,0 +142,0 @@ };

@@ -78,3 +78,4 @@ /// <reference types="./index.d.ts" />

if (Records) {
stringifiedOutputs.push(textDecoder.decode(Records.Payload));
const decodedText = textDecoder.decode(Records.Payload);
stringifiedOutputs.push(decodedText);
}

@@ -104,3 +105,3 @@ }

QuoteEscapeCharacter: csvOptions?.quoteEscapeCharacter || '"',
RecordDelimiter: csvOptions?.recordDelimiter
RecordDelimiter: csvOptions?.recordDelimiter || "\n"
}

@@ -107,0 +108,0 @@ };

2

package.json
{
"name": "kysely-s3-select",
"version": "0.0.2",
"version": "0.1.0",
"description": "Kysely dialect, plugins and other goodies for Amazon S3 Select",

@@ -5,0 +5,0 @@ "repository": "https://github.com/igalklebanov/kysely-s3-select.git",

# kysely-s3-select
Kysely dialect, plugins and other goodies for Amazon S3 Select.
![Powered by TypeScript](https://img.shields.io/badge/powered%20by-typescript-blue.svg)
[Kysely](https://github.com/koskimas/kysely) dialects, plugins and other goodies for [Amazon S3 Select](https://docs.aws.amazon.com/AmazonS3/latest/userguide/selecting-content-from-objects.html).
Inspired by [Thomas Aribart](https://github.com/ThomasAribart)'s great [post](https://dev.to/kumo/type-safe-s3-select-queries-with-kysely-4ge0).
WIP - not ready for production use, waiting on Localstack V2 image to test.
## Installation
#### NPM 7+
```bash
npm i kysely-s3-select
```
#### NPM <7
```bash
npm i kysely-s3-select kysely @aws-sdk/client-s3
```
#### Yarn
```bash
yarn add kysely-s3-select kysely @aws-sdk/client-s3
```
#### PNPM
```bash
pnpm add kysely-s3-select kysely @aws-sdk/client-s3
```
### Deno
This package was not tested in Deno, aws-sdk-v3 might not be supported.
This package uses/extends some [Kysely](https://github.com/koskimas/kysely) types and classes, which are imported using its NPM package name -- not a relative file path or CDN url.
To fix that, add an [`import_map.json`](https://deno.land/manual@v1.26.1/linking_to_external_code/import_maps) file.
```json
{
"imports": {
"kysely": "https://cdn.jsdelivr.net/npm/kysely@0.23.5/dist/esm/index.js"
}
}
```
## Usage
```ts
import { S3Client } from '@aws-sdk/client-s3'
import { Kysely } from 'kysely'
import { S3SelectDialect } from 'kysely-s3-select'
interface ConditionsCSV {
S3Object: Condition
}
interface Condition {
START: string
STOP: string
PATIENT: string
CODE: string
DESCRIPTION: string
}
const conditions = new Kysely<ConditionsCSV>({
dialect: new S3SelectDialect({
bucket: 'synthea-open-data',
client: new S3Client({
region: 'us-east-1', // optional
}),
contentType: 'csv', // one of 'csv' | 'json' | 'parquet'
// csvOptions: { // optional
// allowQuotedRecordDelimiter: false, // optional
// comments?: '#', // optional
// fieldDelimiter?: ',', // optional
// fileHeaderInfo?: 'use', // optional
// quoteCharacter?: '"', // optional
// quoteEscapeCharacter?: '"', // optional
// recordDelimiter?: '\n', // optional
// },
key: 'coherent/unzipped/csv/conditions.csv',
})
})
const results = await conditions
.selectFrom('S3Object')
.where('START', '>=', '2000')
.where('STOP', '!=', '')
.select(['PATIENT as patient', 'DESCRIPTION as description'])
.limit(50)
.execute()
interface PatientBundleJSON {
S3Object: Bundle
}
interface Bundle {
resourceType: 'Bundle'
type: 'transaction'
entry: Entry[]
}
interface Entry {
fullUrl: string
resource: Patient
request: object
}
interface Patient {
resourceType: 'Patient'
id: string
meta: object
text: object
extension: object[]
identifier: object[]
name: {
use: 'official'
family: string
given: string[]
prefix: string[]
}[]
telecom: object[]
gender: 'male' | 'female'
birthDate: string
deceasedDateTime: string
address: object[]
maritalStatus: object
multipleBirthBoolean: boolean
communication: object[]
}
const patientBundle = new Kysely<PatientBundleJSON>({
dialect: new S3SelectDialect({
bucket: 'synthea-open-data',
client: new S3Client({
region: 'us-east-1', // optional
}),
contentType: 'json', // one of 'csv' | 'json' | 'parquet'
// jsonOptions: { // optional
// type: 'document', // optional, one of 'document' | 'lines'
// },
key: 'coherent/unzipped/fhir/Abe604_Frami345_b8dd1798-beef-094d-1be4-f90ee0e6b7d5.json',
})
})
const patient = await patientBundle
.selectFrom(
sql<Partial<Entry['resource']>>`S3Object[*].${sql.ref('entry')}[*].${sql.ref('resource')}`.as('resource'),
)
.where('resource.resourceType', '=', 'Patient')
.select(['resource.id as id', 'resource.name as name'])
.limit(1)
.$castTo<Pick<Patient, 'id' | 'name'>>()
.executeTakeFirstOrThrow()
```
## License
MIT License, see `LICENSE`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc