Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@magnetarjs/core

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magnetarjs/core - npm Package Compare versions

Comparing version 0.2.13 to 0.2.14

2

dist/types/types/actions.d.ts

@@ -58,3 +58,3 @@ import { O } from 'ts-toolbelt';

force?: boolean;
} | Record<string, any> | void, actionConfig?: ActionConfig) => Promise<calledFrom extends 'collection' ? Map<string, DocDataType> : DocDataType>;
} | Record<string, any> | void, actionConfig?: ActionConfig) => Promise<calledFrom extends 'collection' ? Map<string, DocDataType> : DocDataType | undefined>;
/**

@@ -61,0 +61,0 @@ * @returns The new `doc()` instance after inserting. You can access the inserted `id` by checking this returned instance.

@@ -0,14 +1,32 @@

import { O, U } from 'ts-toolbelt';
export declare type DeepPartial<T extends Record<string, any>> = O.Optional<T, keyof T, 'deep'>;
/**
* Joins a list into a dot notation path
* Returns the type for string literals.
*
* When the type is an empty string literal `''` or a generic `string` it returns `never`
*/
declare type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${'' extends P ? '' : '.'}${P}` : never : never;
declare type IsFullStringLiteral<T> = T extends string ? ('' extends T ? false : true) : false;
/**
* Joins two keys into a dot notation path
*
* Stops at arrays. Otherwise it would include `${number}`
*/
declare type Join<K, P> = K extends string ? P extends string ? IsFullStringLiteral<P> extends true ? `${K}.${P}` : K : P extends number ? K : never : never;
declare type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...0[]];
/**
* All possible Object Paths
* All possible Object Paths, branches AND leaves
* @example OPaths<{ a: { b: number } }>
* // returns ['a', 'a.b']
* // returns 'a' | 'a.b'
*/
export declare type OPaths<T, D extends number = 10> = [D] extends [never] ? never : T extends Record<string, any> ? {
[K in keyof T]-?: K extends string | number ? `${K}` | Join<K, OPaths<T[K], Prev[D]>> : never;
}[keyof T] : '';
export declare type OPaths<T, D extends number = 10> = [D] extends [never] ? never : U.Intersect<T, null | undefined> extends never ? T extends Record<string, any> ? {
[K in keyof T]-?: K extends string ? `${K}` | Join<K, OPaths<T[K], Prev[D]>> : never;
}[keyof T] : '' : '';
/**
* All possible Object Paths, but only the leaves
* @example OPaths<{ a: { b: number } }>
* // returns 'a.b'
*/
export declare type OLeaves<T, D extends number = 10> = [D] extends [never] ? '' : U.Intersect<T, null | undefined> extends never ? T extends Record<string, any> ? {
[K in keyof T]-?: IsFullStringLiteral<K> extends true ? Join<K, OLeaves<T[K], Prev[D]>> : '';
}[keyof T] : '' : '';
export {};
{
"name": "@magnetarjs/core",
"version": "0.2.13",
"version": "0.2.14",
"sideEffects": false,

@@ -25,3 +25,3 @@ "description": "Magnetar core library.",

"devDependencies": {
"@magnetarjs/test-utils": "^0.1.11"
"@magnetarjs/test-utils": "^0.1.12"
},

@@ -69,3 +69,3 @@ "keywords": [

},
"gitHead": "012a3daadd83d31238371447e91c11a7e7bef304"
"gitHead": "67effeefcd07d8e1dd1683bf461952db9893002e"
}

@@ -0,7 +1,24 @@

import { O, U, M } from 'ts-toolbelt'
export type DeepPartial<T extends Record<string, any>> = O.Optional<T, keyof T, 'deep'>
/**
* Joins a list into a dot notation path
* Returns the type for string literals.
*
* When the type is an empty string literal `''` or a generic `string` it returns `never`
*/
type Join<K, P> = K extends string | number
? P extends string | number
? `${K}${'' extends P ? '' : '.'}${P}`
type IsFullStringLiteral<T> = T extends string ? ('' extends T ? false : true) : false
/**
* Joins two keys into a dot notation path
*
* Stops at arrays. Otherwise it would include `${number}`
*/
type Join<K, P> = K extends string
? P extends string
? IsFullStringLiteral<P> extends true
? `${K}.${P}`
: K
: P extends number
? K
: never

@@ -14,12 +31,40 @@ : never

/**
* All possible Object Paths
* All possible Object Paths, branches AND leaves
* @example OPaths<{ a: { b: number } }>
* // returns ['a', 'a.b']
* // returns 'a' | 'a.b'
*/
export type OPaths<T, D extends number = 10> = [D] extends [never]
? never
: T extends Record<string, any>
? {
[K in keyof T]-?: K extends string | number ? `${K}` | Join<K, OPaths<T[K], Prev[D]>> : never
}[keyof T]
: U.Intersect<T, null | undefined> extends never
? T extends Record<string, any>
? {
[K in keyof T]-?: K extends string ? `${K}` | Join<K, OPaths<T[K], Prev[D]>> : never
}[keyof T]
: ''
: ''
/**
* All possible Object Paths, but only the leaves
* @example OPaths<{ a: { b: number } }>
* // returns 'a.b'
*/
export type OLeaves<T, D extends number = 10> = [D] extends [never]
? ''
: U.Intersect<T, null | undefined> extends never
? T extends Record<string, any>
? {
[K in keyof T]-?: IsFullStringLiteral<K> extends true ? Join<K, OLeaves<T[K], Prev[D]>> : ''
}[keyof T]
: ''
: ''
// type Test = {
// a: { b: { c: { d: number; e: number } }; inA: string }
// x: string[]
// y: { name: string } | undefined
// z: { [key in string]: { zzz: number[] } }
// z123: { a123: { [key in string]: { zzz: number[] } } }
// }
// export type FlatTestPaths = OPaths<Test, 4>
// export type FlatTestLeaves = OLeaves<Test, 4>
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