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

appwrite-utils

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appwrite-utils - npm Package Compare versions

Comparing version 0.9.93 to 0.9.94

16

dist/migrations/converters.d.ts

@@ -47,2 +47,8 @@ import { DateTime } from "luxon";

/**
* Removes the start and end quotes from a string.
* @param value The string to remove quotes from.
* @return The string with quotes removed.
**/
removeStartEndQuotes(value: string): string;
/**
* Tries to split a string by different separators and returns the split that has the most uniform segment lengths.

@@ -54,2 +60,12 @@ * This can be particularly useful for structured data like phone numbers.

trySplitByDifferentSeparators(value: string): string[];
splitByComma(value: string): string[];
splitByPipe(value: string): string[];
splitBySemicolon(value: string): string[];
splitByColon(value: string): string[];
splitBySlash(value: string): string[];
splitByBackslash(value: string): string[];
splitBySpace(value: string): string[];
splitByDot(value: string): string[];
splitByUnderscore(value: string): string[];
splitByHyphen(value: string): string[];
/**

@@ -56,0 +72,0 @@ * Takes the first element of an array and returns it.

48

dist/migrations/converters.js

@@ -88,2 +88,10 @@ import { DateTime } from "luxon";

/**
* Removes the start and end quotes from a string.
* @param value The string to remove quotes from.
* @return The string with quotes removed.
**/
removeStartEndQuotes(value) {
return value.replace(/^["']|["']$/g, "");
},
/**
* Tries to split a string by different separators and returns the split that has the most uniform segment lengths.

@@ -97,5 +105,5 @@ * This can be particularly useful for structured data like phone numbers.

let bestSplit = [];
let bestScore = -Infinity; // Initialize with a very low score, aiming to maximize it
let bestScore = -Infinity;
for (const separator of separators) {
const split = value.split(separator);
const split = value.split(separator).map((s) => s.trim()); // Ensure we trim spaces
if (split.length <= 1)

@@ -107,6 +115,4 @@ continue; // Skip if no actual splitting occurred

const lengthVariance = lengths.reduce((total, length) => total + Math.pow(length - averageLength, 2), 0) / lengths.length;
// Score based on a combination of the number of segments and how uniform their lengths are
// The assumption is that more segments and lower variance in their lengths are better
// Adjust the scoring formula as needed based on observed data characteristics
const score = split.length - lengthVariance; // Example scoring formula
// Adjust scoring to prioritize splits with lower variance and/or specific segment count if needed
const score = split.length / (1 + lengthVariance); // Adjusted to prioritize lower variance
// Update bestSplit if this split has a better score

@@ -124,2 +130,32 @@ if (score > bestScore) {

},
splitByComma(value) {
return value.split(",");
},
splitByPipe(value) {
return value.split("|");
},
splitBySemicolon(value) {
return value.split(";");
},
splitByColon(value) {
return value.split(":");
},
splitBySlash(value) {
return value.split("/");
},
splitByBackslash(value) {
return value.split("\\");
},
splitBySpace(value) {
return value.split(" ");
},
splitByDot(value) {
return value.split(".");
},
splitByUnderscore(value) {
return value.split("_");
},
splitByHyphen(value) {
return value.split("-");
},
/**

@@ -126,0 +162,0 @@ * Takes the first element of an array and returns it.

@@ -26,3 +26,8 @@ import { ID, InputFile, Query, } from "node-appwrite";

if (converterFunction) {
return converterFunction(value);
if (Array.isArray(value)) {
return value.map((item) => converterFunction(item));
}
else {
return converterFunction(value);
}
}

@@ -68,3 +73,9 @@ else {

// Apply the validation rule
const isValid = validationRule(item, ...resolvedParams);
let isValid = false;
if (Array.isArray(item)) {
isValid = item.every((item) => validationRule(item, ...resolvedParams));
}
else {
isValid = validationRule(item, ...resolvedParams);
}
if (!isValid) {

@@ -71,0 +82,0 @@ console.error(`Validation failed for rule '${action}' with params ${params.join(", ")}`);

2

package.json
{
"name": "appwrite-utils",
"version": "0.9.93",
"version": "0.9.94",
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more.",

@@ -5,0 +5,0 @@ "bin": {

@@ -119,2 +119,13 @@ # AppwriteUtils Package

- `trySplitByDifferentSeparators(value: string): string[]`
- `removeStartEndQuotes(value: string): string`
- `splitByComma(value: string): string[]`
- `splitByPipe(value: string): string[]`
- `splitBySemicolon(value: string): string[]`
- `splitByColon(value: string): string[]`
- `splitBySlash(value: string): string[]`
- `splitByBackslash(value: string): string[]`
- `splitBySpace(value: string): string[]`
- `splitByDot(value: string): string[]`
- `splitByUnderscore(value: string): string[]`
- `splitByHyphen(value: string): string[]`
- `pickFirstElement(value: any[]): any`

@@ -192,2 +203,3 @@ - `pickLastElement(value: any[]): any`

- 0.9.94: Added a bunch of different splitting functions for more fine-grained control and updated how the `trySplitByDifferentSeparators` works to fix the logic. Added converters are above. Also made it so converters and validation actions can take arrays for the item, because why not.
- 0.9.93: Moved relationship resolution to the end

@@ -194,0 +206,0 @@ - 0.9.92: forgot I can't use stupid `import something from '@/utils'` in `esbuild`, stupid, I miss Vite :(

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