Compare commits

..
Author SHA1 Message Date
sharevb 61bfd2a360 feat(new tool): Parquet File Reader
Fix #1516
2025-03-16 19:12:37 +01:00
10 changed files with 604 additions and 611 deletions

No files matched your search

+5 -1
View File
@@ -130,10 +130,12 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDataTable: typeof import('naive-ui')['NDataTable']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
@@ -146,8 +148,11 @@ declare module '@vue/runtime-core' {
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpace: typeof import('naive-ui')['NSpace']
NTable: typeof import('naive-ui')['NTable']
NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
ParquetsReader: typeof import('./src/tools/parquets-reader/parquets-reader.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
@@ -164,7 +169,6 @@ declare module '@vue/runtime-core' {
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SharepointDecoder: typeof import('./src/tools/sharepoint-decoder/sharepoint-decoder.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
+2
View File
@@ -68,6 +68,8 @@
"figue": "^1.2.0",
"fuse.js": "^6.6.2",
"highlight.js": "^11.7.0",
"hyparquet": "^1.9.0",
"hyparquet-compressors": "^1.0.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"js-base64": "^3.7.6",
+507 -538
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -2,7 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as sharepointDecoder } from './sharepoint-decoder';
import { tool as parquetsReader } from './parquets-reader';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -138,7 +138,6 @@ export const toolsByCategory: ToolCategory[] = [
httpStatusCodes,
jsonDiff,
safelinkDecoder,
sharepointDecoder,
],
},
{
@@ -162,6 +161,7 @@ export const toolsByCategory: ToolCategory[] = [
emailNormalizer,
regexTester,
regexMemo,
parquetsReader,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { Parking } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Parquet files Reader',
path: '/parquets-reader',
description: 'Read parquet file as JSON object arrays',
keywords: ['parquet', 'reader'],
component: () => import('./parquets-reader.vue'),
icon: Parking,
createdAt: new Date('2025-02-09'),
});
@@ -0,0 +1,76 @@
<script setup lang="ts">
// import { Buffer } from 'node:buffer';
import { parquetReadObjects } from 'hyparquet';
import { compressors } from 'hyparquet-compressors';
import type { DataTableInst } from 'naive-ui';
const fileInput = ref() as Ref<File | null>;
const error = ref('');
const results = computedAsync(async () => {
const file = fileInput.value;
error.value = '';
if (file == null) {
return null;
}
try {
return await parquetReadObjects({ file: await file.arrayBuffer(), compressors });
}
catch (e: any) {
error.value = e.toString();
return [];
}
});
const resultsJson = computed(() => JSON.stringify(results.value || [], (_, v) => typeof v === 'bigint' ? v.toString() : v, 2));
const columns = computed(() => Object.keys((results.value || [])[0] || {})
.map(h => ({ key: h.replace(/\./g, '\\.'), title: h })));
function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
const tableRef = ref<DataTableInst>();
function downloadCsv() {
tableRef.value?.downloadCsv({ fileName: fileInput.value?.name || 'data' });
}
</script>
<template>
<div style="max-width: 600px;">
<c-card title="Input" mb-2>
<c-file-upload
title="Drag and drop Parquet file here, or click to select a file"
@file-upload="onUpload"
/>
</c-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
<n-tabs v-if="!error" type="line" animated>
<n-tab-pane name="jsonData" tab="JSON Content">
<textarea-copyable :value="resultsJson" language="json" :download-file-name="`${fileInput?.name}.json`" />
</n-tab-pane>
<n-tab-pane v-if="columns.length" name="tabData" tab="Table View">
<div mb-1 flex justify-center>
<n-button @click="downloadCsv">
Export as CSV
</n-button>
</div>
<n-data-table
ref="tableRef"
size="small"
:columns="columns"
:data="results" bordered striped
pagination
/>
</n-tab-pane>
</n-tabs>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { Mailbox } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Sharepoint Share Url Decoder',
path: '/sharepoint-decoder',
description: 'Decode sharepoint.com share urls to "normal" Sharepoint Url',
keywords: ['sharepoint', 'url', 'decoder'],
component: () => import('./sharepoint-decoder.vue'),
icon: Mailbox,
createdAt: new Date('2025-02-09'),
});
@@ -1,18 +0,0 @@
import { describe, expect, it } from 'vitest';
import { decodeSharePointsURL } from './sharepoint-decoder.service';
describe('sharepoint-decoder', () => {
describe('decodeSharePointsURL', () => {
describe('decode outlook sharepoint urls', () => {
it('should decode basic sharepoint urls', () => {
expect(decodeSharePointsURL('https://my-site.sharepoint.com/sites/SBL-AssuranceofLearning/AoL%20Reviews/Forms/AllItems.aspx?FolderCTID=0x0120004A7E52B45BF74940ABEB3A8AA69FF829&id=%2Fsites%2FSBL%2DAssuranceofLearning%2FAoL%20Reviews%2FAnalytics%2FSQL%2EDefinitions%2Fcourse%5Funit%5Fsets%2Esql&viewid=d65c252e%2Db796%2D4457%2D88dd%2D2a8095006fb9&parent=%2Fsites%2FSBL%2DAssuranceofLearning%2FAoL%20Reviews%2FAnalytics%2FSQL%2EDefinitions'))
.toBe('https://my-site.sharepoint.com/sites/SBL-AssuranceofLearning/AoL Reviews/Analytics/SQL.Definitions/course_unit_sets.sql');
});
it('throw on not outlook sharepoint urls', () => {
expect(() => decodeSharePointsURL('https://google.com'))
.toThrow('Invalid SharePoint URL provided');
});
});
});
});
@@ -1,8 +0,0 @@
export function decodeSharePointsURL(sharePointsUrl: string) {
if (!sharePointsUrl.match(/\.sharepoint\.com/)) {
throw new Error('Invalid SharePoint URL provided');
}
const url = new URL(sharePointsUrl);
return `${url.protocol}//${url.hostname}${url.searchParams.get('id')}`;
}
@@ -1,32 +0,0 @@
<script setup lang="ts">
import { decodeSharePointsURL } from './sharepoint-decoder.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const inputSharePointUrl = ref('');
const outputDecodedUrl = computed(() => {
try {
return decodeSharePointsURL(inputSharePointUrl.value);
}
catch (e: any) {
return e.toString();
}
});
</script>
<template>
<div>
<c-input-text
v-model:value="inputSharePointUrl"
raw-text
placeholder="Your input SharePoint Url..."
autofocus
label="Your input SharePoint Url:"
/>
<n-divider />
<n-form-item label="Output decoded URL:">
<TextareaCopyable :value="outputDecodedUrl" :word-wrap="true" />
</n-form-item>
</div>
</template>