Comparing version 1.0.3 to 1.0.4
@@ -153,6 +153,6 @@ type RecursivePartial<T> = { | ||
type SubFilter<T> = T extends number ? Prettify<Pick<AllSubFilters<T>, 'isGreaterThan' | 'isLessThan' | 'is'>> : T extends string ? Prettify<Pick<AllSubFilters<T>, 'contains' | 'endsWith' | 'is' | 'isNot' | 'startsWith'>> : T extends boolean ? Prettify<Pick<AllSubFilters<T>, 'is'>> : T extends Date ? Prettify<Pick<AllSubFilters<T>, 'isGreaterThan' | 'isLessThan' | 'is'>> : never; | ||
type Where<TSchema extends Record<string, unknown>> = { | ||
type Where<TSchema extends Record<string, any>> = { | ||
[TKey in keyof TSchema]: SubFilter<TSchema[TKey]>; | ||
}; | ||
type With<TSchema extends Record<string, unknown>> = { | ||
type With<TSchema extends Record<string, any>> = { | ||
[TKey in keyof TSchema]: TSchema[TKey]; | ||
@@ -168,5 +168,5 @@ }; | ||
} | ||
type To<TSchema extends Record<string, unknown>> = With<TSchema>; | ||
type To<TSchema extends Record<string, any>> = With<TSchema>; | ||
type Variants = 'english' | 'german' | 'japanese'; | ||
export interface Filter<TSchema extends Record<string, unknown> & RoninRecord> { | ||
export interface Filter<TSchema extends Record<string, any> & RoninRecord> { | ||
/** Perform specific matching actions (such as "is", "contains", or "startsWith") on the fields of a record. */ | ||
@@ -183,15 +183,15 @@ where: Partial<Where<TSchema>>; | ||
} | ||
export interface FilterAndMutate<TSchema extends Record<string, unknown> & RoninRecord> extends Filter<TSchema> { | ||
export interface FilterAndMutate<TSchema extends Record<string, any> & RoninRecord> extends Filter<TSchema> { | ||
/** Perform mutations on the fields of a record or add new fields to it. */ | ||
to: Partial<To<TSchema>>; | ||
} | ||
export interface Counter extends Record<string, Filter<Record<string, unknown> & RoninRecord>> { | ||
export interface Counter extends Record<string, Filter<Record<string, any> & RoninRecord>> { | ||
} | ||
export interface Creator extends Record<string, Filter<Record<string, unknown> & RoninRecord>> { | ||
export interface Creator extends Record<string, Filter<Record<string, any> & RoninRecord>> { | ||
} | ||
export interface Dropper extends Record<string, Filter<Record<string, unknown> & RoninRecord>> { | ||
export interface Dropper extends Record<string, Filter<Record<string, any> & RoninRecord>> { | ||
} | ||
export interface Getter extends Record<string, Filter<Record<string, unknown> & RoninRecord>> { | ||
export interface Getter extends Record<string, Filter<Record<string, any> & RoninRecord>> { | ||
} | ||
export interface Setter extends Record<string, FilterAndMutate<Record<string, unknown> & RoninRecord>> { | ||
export interface Setter extends Record<string, FilterAndMutate<Record<string, any> & RoninRecord>> { | ||
} | ||
@@ -213,2 +213,7 @@ export {}; | ||
/** | ||
* Allows for extending the lifetime of the edge worker invocation until the | ||
* provided promise has been resolved. | ||
*/ | ||
waitUntil?: (promise: Promise<unknown>) => void; | ||
/** | ||
* ## 🚧 For internal use only! 🚧 | ||
@@ -215,0 +220,0 @@ * |
@@ -324,3 +324,11 @@ var __defProp = Object.defineProperty; | ||
const modifiableResults = []; | ||
const { hooks } = options || {}; | ||
const { hooks, waitUntil } = options || {}; | ||
if (typeof process === "undefined" && hooks && !waitUntil) { | ||
let message = 'In the case that the "ronin" package receives a value for'; | ||
message += " its `hooks` option, it must also receive a value for its"; | ||
message += " `waitUntil` option. This requirement only applies when using"; | ||
message += " an edge runtime and ensures that the edge worker continues to"; | ||
message += ' execute until all "after" hooks have been executed.'; | ||
throw new Error(message); | ||
} | ||
await Promise.all( | ||
@@ -362,3 +370,3 @@ queries.map((query, index) => { | ||
const queryResult = results[queryIndex]; | ||
invokeHooks(hooks, "after", queries, null, { | ||
const promise = invokeHooks(hooks, "after", queries, null, { | ||
definition: query, | ||
@@ -368,2 +376,4 @@ index: queryIndex, | ||
}); | ||
if (waitUntil) | ||
waitUntil(promise); | ||
} | ||
@@ -370,0 +380,0 @@ return results; |
{ | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"name": "ronin", | ||
@@ -4,0 +4,0 @@ "scripts": { |
26248
717