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

@magnetarjs/types

Package Overview
Dependencies
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magnetarjs/types - npm Package Compare versions

Comparing version 0.12.13 to 0.13.0

169

dist/index.d.ts

@@ -98,2 +98,6 @@ import { Merge } from 'merge-anything';

* Determines the where-filter to be applied.
*
* This is the internal type used by the config state.
* It has no knowledge on the actual types of the data.
* The where clause is defined in a more complex manner at `CollectionInstance["where"]`
*/

@@ -103,5 +107,21 @@ type WhereClause = [string, WhereFilterOp, any];

* Sort by the specified field, optionally in descending order instead of ascending.
*
* This is the internal type used by the config state.
* It has no knowledge on the actual types of the data.
* The orderBy clause is defined in a more complex manner at `CollectionInstance["orderBy"]`
*/
type OrderByClause = [string, ('asc' | 'desc')?];
/**
* Determines a complex queries of where-filter with ANDs and ORs.
*
* This is the internal type used by the config state.
* It has no knowledge on the actual types of the data.
* The orderBy clause is defined in a more complex manner at `CollectionInstance["query"]`
*/
type QueryClause = {
and: WhereClause[] | QueryClause;
} | {
or: WhereClause[] | QueryClause;
};
/**
* The maximum number of items to return.

@@ -111,5 +131,7 @@ */

/**
* Clauses that can filter data in a Collection
* Clauses that can filter data in a Collection.
* This is used for the internal config state. Applying where clauses by the developer is done through `CollectionInstance`.
*/
type Clauses = {
query?: QueryClause[];
where?: WhereClause[];

@@ -121,4 +143,3 @@ orderBy?: OrderByClause[];

type WhereFilterValue<WFO extends WhereFilterOp, V> = WFO extends 'in' | 'not-in' ? V[] : WFO extends `array-contains` ? ArrayValues<V> : V;
/** TODO: replace `WhereClause` with this one */
type WhereClauseTuple<T extends Record<string, any>, Path extends OPathsWithOptional<T>, WhereOp extends WhereFilterOp> = [
type WhereClauseTuple<T extends Record<string, any>, Path extends OPathsWithOptional<T> = OPathsWithOptional<T>, WhereOp extends WhereFilterOp = WhereFilterOp> = [
fieldPath: Path,

@@ -128,2 +149,7 @@ operator: WhereOp,

];
type Query<T extends Record<string, any> = Record<string, any>> = {
or: WhereClauseTuple<T>[] | Query<T>;
} | {
and: WhereClauseTuple<T>[] | Query<T>;
};

@@ -161,3 +187,3 @@ type CollectionInstance<DocDataType extends Record<string, any> = Record<string, any>, GranularTypes extends {

/**
* Returns the open stream promise of this collection, dependant on which `where`/`limit`/`orderBy` filters was used.
* Returns the open stream promise of this collection, dependant on which `where`/`query`/`limit`/`orderBy` filters was used.
*

@@ -170,3 +196,3 @@ * Returns `null` when there is no open stream.

/**
* Close the stream of this collection, dependant on which `where`/`limit`/`orderBy` filters was used.
* Close the stream of this collection, dependant on which `where`/`query`/`limit`/`orderBy` filters was used.
*

@@ -177,3 +203,3 @@ * Does nothing if there is no open stream.

/**
* Close all streams of this collection, no matter which `where`/`limit`/`orderBy` filters were used.
* Close all streams of this collection, no matter which `where`/`query`/`limit`/`orderBy` filters were used.
*

@@ -218,2 +244,6 @@ * Does nothing if there are no open streams.

*/
query: (query: Query<DocDataType>) => CollectionInstance<DocDataType, GranularTypes>;
/**
* Chainable filter. Returns {@link CollectionInstance} with filter applied.
*/
startAfter(docSnapshot: Record<string, any>): CollectionInstance<DocDataType, GranularTypes>;

@@ -227,2 +257,16 @@ startAfter(...fieldValues: unknown[]): CollectionInstance<DocDataType, GranularTypes>;

type StoreName = string;
type DocMetadata = {
data: Record<string, any> | undefined;
id: string;
/**
* In case the doc was returned optimisticly (from the local store data) then `exists` will be `'unknown'`
*/
exists: boolean | 'unknown';
/**
* In case the doc was returned optimisticly (from the local store data) then `metadata` will be absent
*/
metadata?: Record<string, any>;
};
/**

@@ -245,58 +289,2 @@ * Returns a _deep_ Partial of `O`, where all props & nested props are optional

/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyWritePayload<DocDataType extends Record<string, any> = Record<string, any>> = (payload: PartialDeep<DocDataType>, docId?: string | void) => PartialDeep<DocDataType>;
/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyDeletePropPayload = (payload: string | string[]) => string | string[];
/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyReadPayload = (payload: Record<string, any> | void, docId?: string | void) => Record<string, any> | void;
/**
* These functions will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyPayloadFnMap<DocDataType extends Record<string, any> = Record<string, any>> = {
insert?: ModifyWritePayload<DocDataType>;
merge?: ModifyWritePayload<DocDataType>;
assign?: ModifyWritePayload<DocDataType>;
replace?: ModifyWritePayload<DocDataType>;
write?: ModifyWritePayload<DocDataType>;
deleteProp?: ModifyDeletePropPayload;
read?: ModifyReadPayload;
stream?: ModifyReadPayload;
fetch?: ModifyReadPayload;
};
/**
* These functions will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyPayloadFnsMap = {
insert: ModifyWritePayload[];
merge: ModifyWritePayload[];
assign: ModifyWritePayload[];
replace: ModifyWritePayload[];
write: ModifyWritePayload[];
deleteProp: ModifyDeletePropPayload[];
delete: never[];
read: ModifyReadPayload[];
stream: ModifyReadPayload[];
fetch: ModifyReadPayload[];
};
type StoreName = string;
type DocMetadata = {
data: Record<string, any> | undefined;
id: string;
/**
* In case the doc was returned optimisticly (from the local store data) then `exists` will be `'unknown'`
*/
exists: boolean | 'unknown';
/**
* In case the doc was returned optimisticly (from the local store data) then `metadata` will be absent
*/
metadata?: Record<string, any>;
};
/**
* Can be used to modify docs that come in from 'stream' or 'fetch' actions, before they are added to your store data. When returning `undefined` they will be discarded & won't be added to the store data.

@@ -688,2 +676,44 @@ */

/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyWritePayload<DocDataType extends Record<string, any> = Record<string, any>> = (payload: PartialDeep<DocDataType>, docId?: string | void) => PartialDeep<DocDataType>;
/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyDeletePropPayload = (payload: string | string[]) => string | string[];
/**
* This function will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyReadPayload = (payload: Record<string, any> | void, docId?: string | void) => Record<string, any> | void;
/**
* These functions will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyPayloadFnMap<DocDataType extends Record<string, any> = Record<string, any>> = {
insert?: ModifyWritePayload<DocDataType>;
merge?: ModifyWritePayload<DocDataType>;
assign?: ModifyWritePayload<DocDataType>;
replace?: ModifyWritePayload<DocDataType>;
write?: ModifyWritePayload<DocDataType>;
deleteProp?: ModifyDeletePropPayload;
read?: ModifyReadPayload;
stream?: ModifyReadPayload;
fetch?: ModifyReadPayload;
};
/**
* These functions will be executed everytime BEFORE the related action is triggered. The function defined will receive the payload of the action. You can then modify and return this payload.
*/
type ModifyPayloadFnsMap = {
insert: ModifyWritePayload[];
merge: ModifyWritePayload[];
assign: ModifyWritePayload[];
replace: ModifyWritePayload[];
write: ModifyWritePayload[];
deleteProp: ModifyDeletePropPayload[];
delete: never[];
read: ModifyReadPayload[];
stream: ModifyReadPayload[];
fetch: ModifyReadPayload[];
};
/**
* Execution order per action or action type.

@@ -724,2 +754,3 @@ */

type ModuleConfig<DocDataType extends Record<string, any> = Record<string, any>> = {
query?: QueryClause[];
where?: WhereClause[];

@@ -1065,7 +1096,7 @@ orderBy?: OrderByClause[];

declare enum PathFilterIdentifier {
'KEY' = "modulePath + JSON.stringify({ where, orderBy, startAfter, limit })"
'KEY' = "modulePath + JSON.stringify({ query, where, orderBy, startAfter, limit })"
}
/**
* Creates the `key` for the Maps used to cache certain values throughout the lifecycle of an instance.
* @returns `modulePath + ' /// ' + JSON.stringify({ where, orderBy, startAfter, limit })`
* @returns `modulePath + ' /// ' + JSON.stringify({ query, where, orderBy, startAfter, limit })`
*/

@@ -1077,7 +1108,7 @@ declare function getPathFilterIdentifier(modulePath: string, moduleConfig: ModuleConfig): PathFilterIdentifier;

declare enum PathWhereOrderByIdentifier {
'KEY' = "modulePath + JSON.stringify({ where, orderBy })"
'KEY' = "modulePath + JSON.stringify({ query, where, orderBy })"
}
/**
* Creates the `key` for the Maps used to cache the FetchMetaDataCollection throughout the lifecycle of an instance.
* @returns `modulePath + ' /// ' + JSON.stringify({ where, orderBy })`
* @returns `modulePath + ' /// ' + JSON.stringify({ query, where, orderBy })`
*/

@@ -1089,10 +1120,10 @@ declare function getPathWhereOrderByIdentifier(modulePath: string, moduleConfig: ModuleConfig): PathWhereOrderByIdentifier;

declare enum PathWhereIdentifier {
'KEY' = "modulePath + JSON.stringify({ where, orderBy })"
'KEY' = "modulePath + JSON.stringify({ query, where, orderBy })"
}
/**
* Creates the `key` for the Maps used to cache the FetchMetaDataCollection throughout the lifecycle of an instance.
* @returns `modulePath + ' /// ' + JSON.stringify({ where, orderBy })`
* @returns `modulePath + ' /// ' + JSON.stringify({ query, where, orderBy })`
*/
declare function getPathWhereIdentifier(modulePath: string, moduleConfig: ModuleConfig): PathWhereIdentifier;
export { ActionConfig, ActionName, ActionTernary, ActionType, Clauses, CollectionFn, CollectionInstance, CollectionName, DoOnFetch, DoOnFetchCount, DoOnStream, DoOnStreamFns, DocFn, DocInstance, DocMetadata, Equals, EqualsAnyOfUnion, EventFn, EventFnBefore, EventFnError, EventFnRevert, EventFnSuccess, EventName, EventNameFnMap, EventNameFnsMap, ExecutionOrderConfig, FetchCountResponse, FetchMetaDataCollection, FetchPromises, FetchResponse, GlobalConfig, Intersect, IsFullStringLiteral, Limit, MODULE_IDENTIFIER_SPLIT, MagnetarDeleteAction, MagnetarDeletePropAction, MagnetarFetchAction, MagnetarFetchCountAction, MagnetarInsertAction, MagnetarInstance, MagnetarPlugin, MagnetarStreamAction, MagnetarWriteAction, MergeDeep, ModifyDeletePropPayload, ModifyPayloadFnMap, ModifyPayloadFnsMap, ModifyReadPayload, ModifyReadResponseFnMap, ModifyReadResponseFnsMap, ModifyWritePayload, ModuleConfig, MustExecuteOnRead, OLeaves, OPathsWithOptional, OPathsWithoutOptional, OnAddedFn, OnModifiedFn, OnRemovedFn, OrderByClause, PartialDeep, PathFilterIdentifier, PathWhereIdentifier, PathWhereOrderByIdentifier, PluginActionPayloadBase, PluginActionTernary, PluginDeleteAction, PluginDeleteActionPayload, PluginDeletePropAction, PluginDeletePropActionPayload, PluginFetchAction, PluginFetchActionPayload, PluginFetchCountAction, PluginFetchCountActionPayload, PluginInsertAction, PluginInsertActionPayload, PluginInstance, PluginModuleConfig, PluginModuleSetupPayload, PluginRevertAction, PluginRevertActionPayload, PluginStreamAction, PluginStreamActionPayload, PluginWriteAction, PluginWriteActionPayload, StoreName, StreamResponse, SyncBatch, WhereClause, WhereClauseTuple, WhereFilterOp, WhereFilterValue, WriteLock, actionNameTypeMap, getPathFilterIdentifier, getPathWhereIdentifier, getPathWhereOrderByIdentifier };
export { ActionConfig, ActionName, ActionTernary, ActionType, Clauses, CollectionFn, CollectionInstance, CollectionName, DoOnFetch, DoOnFetchCount, DoOnStream, DoOnStreamFns, DocFn, DocInstance, DocMetadata, Equals, EqualsAnyOfUnion, EventFn, EventFnBefore, EventFnError, EventFnRevert, EventFnSuccess, EventName, EventNameFnMap, EventNameFnsMap, ExecutionOrderConfig, FetchCountResponse, FetchMetaDataCollection, FetchPromises, FetchResponse, GlobalConfig, Intersect, IsFullStringLiteral, Limit, MODULE_IDENTIFIER_SPLIT, MagnetarDeleteAction, MagnetarDeletePropAction, MagnetarFetchAction, MagnetarFetchCountAction, MagnetarInsertAction, MagnetarInstance, MagnetarPlugin, MagnetarStreamAction, MagnetarWriteAction, MergeDeep, ModifyDeletePropPayload, ModifyPayloadFnMap, ModifyPayloadFnsMap, ModifyReadPayload, ModifyReadResponseFnMap, ModifyReadResponseFnsMap, ModifyWritePayload, ModuleConfig, MustExecuteOnRead, OLeaves, OPathsWithOptional, OPathsWithoutOptional, OnAddedFn, OnModifiedFn, OnRemovedFn, OrderByClause, PartialDeep, PathFilterIdentifier, PathWhereIdentifier, PathWhereOrderByIdentifier, PluginActionPayloadBase, PluginActionTernary, PluginDeleteAction, PluginDeleteActionPayload, PluginDeletePropAction, PluginDeletePropActionPayload, PluginFetchAction, PluginFetchActionPayload, PluginFetchCountAction, PluginFetchCountActionPayload, PluginInsertAction, PluginInsertActionPayload, PluginInstance, PluginModuleConfig, PluginModuleSetupPayload, PluginRevertAction, PluginRevertActionPayload, PluginStreamAction, PluginStreamActionPayload, PluginWriteAction, PluginWriteActionPayload, Query, QueryClause, StoreName, StreamResponse, SyncBatch, WhereClause, WhereClauseTuple, WhereFilterOp, WhereFilterValue, WriteLock, actionNameTypeMap, getPathFilterIdentifier, getPathWhereIdentifier, getPathWhereOrderByIdentifier };

@@ -50,26 +50,26 @@ "use strict";

var PathFilterIdentifier = /* @__PURE__ */ ((PathFilterIdentifier2) => {
PathFilterIdentifier2["KEY"] = "modulePath + JSON.stringify({ where, orderBy, startAfter, limit })";
PathFilterIdentifier2["KEY"] = "modulePath + JSON.stringify({ query, where, orderBy, startAfter, limit })";
return PathFilterIdentifier2;
})(PathFilterIdentifier || {});
function getPathFilterIdentifier(modulePath, moduleConfig) {
const { where, orderBy, startAfter, limit } = moduleConfig;
const config = JSON.stringify({ where, orderBy, startAfter, limit });
const { query, where, orderBy, startAfter, limit } = moduleConfig;
const config = JSON.stringify({ query, where, orderBy, startAfter, limit });
return `${modulePath}${MODULE_IDENTIFIER_SPLIT}${config}`;
}
var PathWhereOrderByIdentifier = /* @__PURE__ */ ((PathWhereOrderByIdentifier2) => {
PathWhereOrderByIdentifier2["KEY"] = "modulePath + JSON.stringify({ where, orderBy })";
PathWhereOrderByIdentifier2["KEY"] = "modulePath + JSON.stringify({ query, where, orderBy })";
return PathWhereOrderByIdentifier2;
})(PathWhereOrderByIdentifier || {});
function getPathWhereOrderByIdentifier(modulePath, moduleConfig) {
const { where, orderBy } = moduleConfig;
const config = JSON.stringify({ where, orderBy });
const { query, where, orderBy } = moduleConfig;
const config = JSON.stringify({ query, where, orderBy });
return `${modulePath}${MODULE_IDENTIFIER_SPLIT}${config}`;
}
var PathWhereIdentifier = /* @__PURE__ */ ((PathWhereIdentifier2) => {
PathWhereIdentifier2["KEY"] = "modulePath + JSON.stringify({ where, orderBy })";
PathWhereIdentifier2["KEY"] = "modulePath + JSON.stringify({ query, where, orderBy })";
return PathWhereIdentifier2;
})(PathWhereIdentifier || {});
function getPathWhereIdentifier(modulePath, moduleConfig) {
const { where, orderBy } = moduleConfig;
const config = JSON.stringify({ where, orderBy });
const { query, where, orderBy } = moduleConfig;
const config = JSON.stringify({ query, where, orderBy });
return `${modulePath}${MODULE_IDENTIFIER_SPLIT}${config}`;

@@ -76,0 +76,0 @@ }

{
"name": "@magnetarjs/types",
"version": "0.12.13",
"version": "0.13.0",
"sideEffects": false,

@@ -59,2 +59,3 @@ "description": "Magnetar shared types",

"scripts": {
"typecheck": "tsc --noEmit",
"build": "tsup src/index.ts --clean --format esm,cjs --dts",

@@ -61,0 +62,0 @@ "dev": "pnpm build --watch"

Sorry, the diff of this file is not supported yet

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