Comparing version 1.0.63 to 1.0.64
export declare const start_profiler: () => Promise<void>; | ||
export declare const stop_profiler: () => Promise<void>; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const deep_merge: (target: any, source: any) => any; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface error_type { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ declare type type_string = 'Object' | 'Number' | 'Boolean' | 'String' | 'Null' | 'Array' | 'RegExp' | 'Function' | 'Undefined'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const stable_sort: (arr: any, compare: any) => any; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const path_to_string: (path: any) => string; | ||
export declare const string_to_path: (str: any) => any; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const orma_introspect: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<import("./introspector/introspector").orma_schema>; | ||
export declare const orma_query: <Schema extends import("./types/schema_types").DeepReadonlyObject<import("./introspector/introspector").orma_schema>, Query extends import("./types/query/query_types").OrmaQuery<Schema>>(raw_query: Query, orma_schema_input: Schema, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>, validation_function: (query: any) => any[]) => Promise<(import("./types/query/query_result_types").StripKeywords<import("./types/query/query_result_types").WrapInArrays<import("./types/query/query_result_types").AddSchemaTypes<Schema, Query, unknown>>> & { | ||
export declare const orma_query: <Schema extends import("./types/schema_types").DeepReadonlyObject<import("./introspector/introspector").orma_schema>, Query extends import("./types/query/query_types").OrmaQuery<Schema>>(raw_query: Query, orma_schema_input: Schema, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>, validation_function: (query: any) => any[]) => Promise<(import("./types/query/query_result_types").QueryResult<Schema, Query, never> & { | ||
$success: true; | ||
@@ -4,0 +4,0 @@ }) | { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
import { orma_schema } from './introspector'; | ||
export declare const migrator: (target_schema: orma_schema, database_schema?: orma_schema) => void; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const apply_inherit_operations_macro: (mutation: any) => void; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../../introspector/introspector'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { PathedRecord } from '../types'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../introspector/introspector'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { error_type } from '../helpers/error_handling'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const verify_independence: (mutation: any, orma_query: (query: any) => Promise<any>) => Promise<void>; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../introspector/introspector'; |
@@ -53,5 +53,7 @@ "use strict"; | ||
.filter(el => el !== undefined); | ||
const query_results = await mysql_function(query_statements); | ||
const new_tier_results = (0, exports.add_foreign_key_indexes)(query_statements, query_results, mutation, orma_schema); | ||
tier_results = Object.assign(Object.assign({}, tier_results), new_tier_results); | ||
if (query_statements.length > 0) { | ||
const query_results = await mysql_function(query_statements); | ||
const new_tier_results = (0, exports.add_foreign_key_indexes)(query_statements, query_results, mutation, orma_schema); | ||
tier_results = Object.assign(Object.assign({}, tier_results), new_tier_results); | ||
} | ||
} | ||
@@ -58,0 +60,0 @@ // merge database rows into mutation |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { error_type } from '../../helpers/error_handling'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../../introspector/introspector'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const apply_escape_macro: (query: any) => void; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../../introspector/introspector'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { orma_schema } from '../../introspector/introspector'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ declare type select_expr = {}; |
@@ -0,0 +0,0 @@ // interface query { |
@@ -0,0 +0,0 @@ import { error_type } from '../helpers/error_handling'; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -10,3 +10,3 @@ import { error_type } from '../helpers/error_handling'; | ||
export declare const orma_nester: (results: [string[], Record<string, unknown>[]][], query: any, orma_schema: orma_schema) => {}; | ||
export declare const orma_query: <Schema extends import("../types/schema_types").DeepReadonlyObject<orma_schema>, Query extends OrmaQuery<Schema>>(raw_query: Query, orma_schema_input: Schema, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>, validation_function: (query: any) => any[]) => Promise<(import("../types/query/query_result_types").StripKeywords<import("../types/query/query_result_types").WrapInArrays<import("../types/query/query_result_types").AddSchemaTypes<Schema, Query, unknown>>> & { | ||
export declare const orma_query: <Schema extends import("../types/schema_types").DeepReadonlyObject<orma_schema>, Query extends OrmaQuery<Schema>>(raw_query: Query, orma_schema_input: Schema, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>, validation_function: (query: any) => any[]) => Promise<(QueryResult<Schema, Query, never> & { | ||
$success: true; | ||
@@ -13,0 +13,0 @@ }) | { |
@@ -106,3 +106,3 @@ "use strict"; | ||
if (errors.length > 0) { | ||
return { | ||
throw { | ||
$success: false, | ||
@@ -109,0 +109,0 @@ errors, |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ // export type CreateTableStatement = ({ |
import { error_type } from "../helpers/error_handling"; | ||
export declare const validator: (query: any, schema: any) => error_type[]; |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export declare type Path = (string | number)[]; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { XOR } from '../helper_types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -1,20 +0,8 @@ | ||
import { IsEqual } from '../helper_types'; | ||
import { GetAllEntities, GetFields, GetFieldType, Keyword, OrmaSchema } from '../schema_types'; | ||
import { OrmaQuery } from './query_types'; | ||
export declare type QueryResult<Schema extends OrmaSchema, Query extends OrmaQuery<Schema>> = StripKeywords<WrapInArrays<AddSchemaTypes<Schema, Query>>>; | ||
export declare type AddSchemaTypes<Schema extends OrmaSchema, Obj, ParentKey extends string | unknown = unknown> = { | ||
[Key in keyof Obj]: IsSubquery<Obj[Key]> extends true ? AddSchemaTypes<Schema, Obj[Key], Key> : Obj extends { | ||
export declare type QueryResult<Schema extends OrmaSchema, Query extends object, Entity extends GetAllEntities<Schema> = never> = { | ||
[Key in keyof Query]: Key extends Keyword ? never : Query[Key] extends { | ||
$from: GetAllEntities<Schema>; | ||
} ? GetSchemaTypeForField<Schema, Obj['$from'], Key, Obj[Key]> : ParentKey extends GetAllEntities<Schema> ? GetSchemaTypeForField<Schema, ParentKey, Key, Obj[Key]> : any; | ||
} ? QueryResult<Schema, Query[Key], Query[Key]['$from']>[] : Key extends GetAllEntities<Schema> ? Query[Key] extends object ? Exclude<keyof Query[Key], Keyword> extends never ? 'a' : QueryResult<Schema, Query[Key], Key>[] : 'b' : GetSchemaTypeForField<Schema, Entity, Key, Query[Key]>; | ||
}; | ||
declare type GetSchemaTypeForField<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>, Key, Value> = IsEqual<Value, true> extends true ? Key extends GetFields<Schema, Entity> ? GetFieldType<Schema, Entity, Key> : any : Value extends GetFields<Schema, Entity> ? GetFieldType<Schema, Entity, Value> : any; | ||
export declare type WrapInArrays<Obj> = Obj extends object ? { | ||
[Key in keyof Obj]: IsSubquery<Obj[Key]> extends true ? WrapInArrays<Obj[Key]>[] : WrapInArrays<Obj[Key]>; | ||
} : Obj; | ||
export declare type IsSubquery<Obj> = Obj extends object ? Obj extends { | ||
$from: string; | ||
} ? true : {} extends StripKeywords<Obj> ? false : true : false; | ||
export declare type StripKeywords<Obj> = Obj extends object ? Omit<{ | ||
[Key in keyof Obj]: StripKeywords<Obj[Key]>; | ||
}, Keyword> : Obj; | ||
declare type GetSchemaTypeForField<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>, Key, Value> = Value extends true ? Key extends GetFields<Schema, Entity> ? GetFieldType<Schema, Entity, Key> : any : Value extends GetFields<Schema, Entity> ? GetFieldType<Schema, Entity, Value> : any; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const introspector_1 = require("../../introspector/introspector"); | ||
const tests = () => { | ||
{ | ||
const test_schema = (0, introspector_1.as_orma_schema)({ | ||
@@ -11,2 +11,3 @@ products: { | ||
vendor_id: { | ||
data_type: 'bigint', | ||
references: { | ||
@@ -25,3 +26,5 @@ vendors: { | ||
}, | ||
quantity: {}, | ||
name: { | ||
data_type: 'varchar' | ||
}, | ||
$indexes: [], | ||
@@ -58,11 +61,10 @@ }, | ||
}); | ||
const as_query = (value) => { | ||
return {}; | ||
}; | ||
const query_response = (query) => ''; | ||
{ | ||
// data props propagate as arrays | ||
const result = as_query({ | ||
const result = query_response({ | ||
products: { | ||
$from: 'products', | ||
id: true, | ||
vendor_id: true, | ||
name: true, | ||
}, | ||
@@ -72,3 +74,3 @@ }); | ||
result.products[0].id; | ||
result.products[0].vendor_id; | ||
result.products[0].name; | ||
// @ts-expect-error | ||
@@ -78,128 +80,36 @@ result.vendors; | ||
{ | ||
const t = as_query({ | ||
// infers entity name from prop | ||
const result = query_response({ | ||
products: { | ||
id: true, | ||
id: true | ||
}, | ||
}); | ||
result.products.slice(); | ||
result.products[0].id; | ||
} | ||
{ | ||
// handles deep nesting | ||
const result = as_query({ | ||
// allows prop renaming | ||
const result = query_response({ | ||
products: { | ||
images: { | ||
image_urls: { | ||
$from: 'image_urls', | ||
}, | ||
}, | ||
my_id: 'id' | ||
}, | ||
}); | ||
result.products[0].images[0].image_urls.slice(); | ||
} | ||
{ | ||
// works on computed field | ||
const result = as_query({ | ||
products: { | ||
sum_quantity: { | ||
$sum: 'quantity', | ||
}, | ||
}, | ||
}); | ||
result.products[0].sum_quantity; | ||
} | ||
{ | ||
// ignores keywords | ||
const result = as_query({ | ||
products: { | ||
id: true, | ||
$limit: 2, | ||
}, | ||
}); | ||
result.products[0].id; | ||
// @ts-expect-error | ||
result.products[0].$limit; | ||
} | ||
{ | ||
// to make this recognize as a query, you would have to add a data field like id: true or | ||
// a $from: 'products' prop | ||
const result = as_query({ | ||
products: {}, | ||
}); | ||
result.products.slice(); | ||
const my_id = result.products[0].my_id; | ||
const expect = true; | ||
} | ||
{ | ||
// propagates field types | ||
const result = as_query({ | ||
// allows nesting | ||
const result = query_response({ | ||
products: { | ||
id: true, | ||
images: { | ||
products: { | ||
name: true | ||
} | ||
} | ||
}, | ||
}); | ||
const expect = true; | ||
result.products.slice(); | ||
result.products[0].images[0].products[0].name; | ||
} | ||
{ | ||
// handles renamed entities | ||
const result = as_query({ | ||
my_images: { | ||
$from: 'images', | ||
url: true, | ||
}, | ||
}); | ||
const expect = true; | ||
} | ||
{ | ||
const good = { | ||
a: 12, | ||
c: { | ||
y: [ | ||
{ | ||
z: 1, | ||
}, | ||
], | ||
}, | ||
}; | ||
const bad1 = { | ||
c: { | ||
y: [ | ||
{ | ||
// @ts-expect-error | ||
$q: 2, | ||
}, | ||
], | ||
}, | ||
}; | ||
const bad2 = { | ||
// @ts-expect-error | ||
$b: 1, | ||
}; | ||
const bad3 = { | ||
// @ts-expect-error | ||
$d: { | ||
test: true, | ||
}, | ||
}; | ||
} | ||
{ | ||
// has data props | ||
const good1 = true; | ||
// has a $from prop | ||
const good2 = true; | ||
// this is technically not a subquery, since it has no data props | ||
const bad = false; | ||
// empty object is also not a subquery | ||
const bad2 = false; | ||
} | ||
{ | ||
// AddSchemaTypes | ||
{ | ||
const expect = true; | ||
} | ||
{ | ||
const expect = true; | ||
} | ||
{ | ||
const expect = true; | ||
} | ||
{ | ||
const expect = true; | ||
} | ||
} | ||
}; | ||
} |
export {}; |
@@ -25,2 +25,6 @@ "use strict"; | ||
}; | ||
const q = (query) => { | ||
const a = ''; | ||
return a; | ||
}; | ||
const query = (0, query_1.as_orma_query)(schema, { | ||
@@ -27,0 +31,0 @@ my_products: { |
@@ -0,0 +0,0 @@ import { Pluck } from '../helper_types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { Edge } from '../helpers/schema_helpers'; |
"use strict"; | ||
// generate type for orma schema which plays well with as const declarations | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "orma", | ||
"version": "1.0.63", | ||
"version": "1.0.64", | ||
"description": "A declarative relational syncronous orm", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -0,0 +0,0 @@ ## Status |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
399086
10142