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

fireschema

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fireschema - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

dist/__tests__/controller.query-utils.test.d.ts

2

dist/__tests__/index.test.d.ts

@@ -1,1 +0,1 @@

export {};
export {}

@@ -1,2 +0,4 @@

export declare const _: (n: number) => string;
export declare const join: (separator: string) => (array: (string | null)[]) => string | null;
export declare const _: (n: number) => string
export declare const join: (
separator: string,
) => (array: (string | null)[]) => string | null

@@ -1,5 +0,9 @@

import { Fireschema } from './types';
export declare const dataSchema: <T>(options: Fireschema.DataSchemaOptions<T>) => Fireschema.DataSchemaOptions<T>;
export declare const fireschema: <T extends Fireschema.RootOptions.All>(schema: T) => {
rendered: string;
};
import { Fireschema } from './types'
export declare const dataSchema: <T>(
options: Fireschema.DataSchemaOptions<T>,
) => Fireschema.DataSchemaOptions<T>
export declare const fireschema: <T extends Fireschema.RootOptions.All>(
schema: T,
) => {
rendered: string
}

@@ -1,30 +0,85 @@

import { firestore as fadmin } from 'firebase-admin';
import { firestore as fweb } from 'firebase/app';
import { firestore as fadmin } from 'firebase-admin'
import { firestore as fweb } from 'firebase/app'
export declare namespace FireTypes {
type Env<F, W, A> = F extends fweb.Firestore ? W : A;
type DocumentValue = DocumentObject | string | number | boolean | null | Date | DocumentValue[] | Timestamp | DocumentRef<DocumentObject>;
type DocumentObject = {
[key: string]: DocumentValue;
};
type DocFieldToWrite<T, F extends Firestore = Firestore> = T extends Timestamp ? Timestamp<F> : T;
type DocDataToWrite<T, F extends Firestore = Firestore> = {
[K in keyof T]: DocFieldToWrite<T[K], F> | FieldValue<F>;
};
type Firestore = fweb.Firestore | fadmin.Firestore;
type FieldValue<F extends Firestore = Firestore> = Env<F, fweb.FieldValue, fadmin.FieldValue>;
type Timestamp<F extends Firestore = Firestore> = Env<F, fweb.Timestamp, fadmin.Timestamp>;
type FieldValueClass = typeof fweb.FieldValue | typeof fadmin.FieldValue;
type TimestampClass = typeof fweb.Timestamp | typeof fadmin.Timestamp;
type SetOptions = fweb.SetOptions | FirebaseFirestore.SetOptions;
type DocumentData = fweb.DocumentData | fadmin.DocumentData;
type CollectionRef<T, F extends Firestore = Firestore> = Env<F, fweb.CollectionReference<T>, fadmin.CollectionReference<T>>;
type Query<T, F extends Firestore = Firestore> = Env<F, fweb.Query<T>, fadmin.Query<T>>;
type FirestoreDataConverter<T, F extends Firestore = Firestore> = Env<F, fweb.FirestoreDataConverter<T>, FirebaseFirestore.FirestoreDataConverter<T>>;
type DocumentRef<T, F extends Firestore = Firestore> = Env<F, fweb.DocumentReference<T>, fadmin.DocumentReference<T>>;
type DocumentSnap<T, F extends Firestore = Firestore> = Env<F, fweb.DocumentSnapshot<T>, fadmin.DocumentSnapshot<T>>;
type QuerySnap<T, F extends Firestore = Firestore> = Env<F, fweb.QuerySnapshot<T>, fadmin.QuerySnapshot<T>>;
type QueryDocumentSnap<T, F extends Firestore = Firestore> = Env<F, fweb.QueryDocumentSnapshot<T>, fadmin.QueryDocumentSnapshot<T>>;
type SnapshotOptions = fweb.SnapshotOptions;
type Transaction<F extends Firestore> = Env<F, fweb.Transaction, fadmin.Transaction>;
type SetResult<F extends Firestore> = Env<F, ReturnType<fweb.DocumentReference['set']>, ReturnType<fadmin.DocumentReference['set']>>;
type Env<F, W, A> = F extends fweb.Firestore ? W : A
type DocumentValue =
| DocumentObject
| string
| number
| boolean
| null
| Date
| DocumentValue[]
| Timestamp
| DocumentRef<DocumentObject>
type DocumentObject = {
[key: string]: DocumentValue
}
type DocFieldToWrite<T, F extends Firestore = Firestore> = T extends Timestamp
? Timestamp<F>
: T
type DocDataToWrite<T, F extends Firestore = Firestore> = {
[K in keyof T]: DocFieldToWrite<T[K], F> | FieldValue<F>
}
type Firestore = fweb.Firestore | fadmin.Firestore
type FieldValue<F extends Firestore = Firestore> = Env<
F,
fweb.FieldValue,
fadmin.FieldValue
>
type Timestamp<F extends Firestore = Firestore> = Env<
F,
fweb.Timestamp,
fadmin.Timestamp
>
type FieldValueClass = typeof fweb.FieldValue | typeof fadmin.FieldValue
type TimestampClass = typeof fweb.Timestamp | typeof fadmin.Timestamp
type SetOptions = fweb.SetOptions | FirebaseFirestore.SetOptions
type DocumentData = fweb.DocumentData | fadmin.DocumentData
type CollectionRef<T, F extends Firestore = Firestore> = Env<
F,
fweb.CollectionReference<T>,
fadmin.CollectionReference<T>
>
type Query<T, F extends Firestore = Firestore> = Env<
F,
fweb.Query<T>,
fadmin.Query<T>
>
type FirestoreDataConverter<T, F extends Firestore = Firestore> = Env<
F,
fweb.FirestoreDataConverter<T>,
FirebaseFirestore.FirestoreDataConverter<T>
>
type DocumentRef<T, F extends Firestore = Firestore> = Env<
F,
fweb.DocumentReference<T>,
fadmin.DocumentReference<T>
>
type DocumentSnap<T, F extends Firestore = Firestore> = Env<
F,
fweb.DocumentSnapshot<T>,
fadmin.DocumentSnapshot<T>
>
type QuerySnap<T, F extends Firestore = Firestore> = Env<
F,
fweb.QuerySnapshot<T>,
fadmin.QuerySnapshot<T>
>
type QueryDocumentSnap<T, F extends Firestore = Firestore> = Env<
F,
fweb.QueryDocumentSnapshot<T>,
fadmin.QueryDocumentSnapshot<T>
>
type SnapshotOptions = fweb.SnapshotOptions
type Transaction<F extends Firestore> = Env<
F,
fweb.Transaction,
fadmin.Transaction
>
type SetResult<F extends Firestore> = Env<
F,
ReturnType<fweb.DocumentReference['set']>,
ReturnType<fadmin.DocumentReference['set']>
>
}

@@ -1,4 +0,5 @@

export * from './fireschema';
export * from './firestore';
export * from './constants';
export * from './controller';
export * from './factories';
export * from './types';
export * from './utils';

@@ -13,5 +13,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./fireschema"), exports);
__exportStar(require("./firestore"), exports);
__exportStar(require("./constants"), exports);
__exportStar(require("./controller"), exports);
__exportStar(require("./factories"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./utils"), exports);
import is from '@sindresorhus/is';
import type * as Type from 'type-fest';
export { is };
export type { Type };

@@ -1,2 +0,5 @@

import { Fireschema } from '../types';
export declare const renderCollections: (collections: Fireschema.CollectionOptions.Children, pIndent: number) => string | null;
import { Fireschema } from '../types'
export declare const renderCollections: (
collections: Fireschema.CollectionOptions.Children,
pIndent: number,
) => string | null

@@ -1,2 +0,5 @@

import { Fireschema } from '../types';
export declare const renderFunctions: ($functions: Fireschema.FunctionsOptions, pIndent: number) => string;
import { Fireschema } from '../types'
export declare const renderFunctions: (
$functions: Fireschema.FunctionsOptions,
pIndent: number,
) => string

@@ -1,2 +0,5 @@

import { Fireschema } from '../types';
export declare const renderRoot: ($functions: Fireschema.FunctionsOptions, collections: Fireschema.CollectionOptions.Children) => (string | null)[];
import { Fireschema } from '../types'
export declare const renderRoot: (
$functions: Fireschema.FunctionsOptions,
collections: Fireschema.CollectionOptions.Children,
) => (string | null)[]

@@ -1,2 +0,8 @@

import { Fireschema } from '../types';
export declare const renderRules: ($allow: Fireschema.AllowOptions, $schema: Fireschema.DataSchemaOptions<any> | Fireschema.DataSchemaOptions<any>[], pIndent: number) => string | null;
import { Fireschema } from '../types'
export declare const renderRules: (
$allow: Fireschema.AllowOptions,
$schema:
| Fireschema.DataSchemaOptions<any>
| Fireschema.DataSchemaOptions<any>[],
pIndent: number,
) => string | null

@@ -1,47 +0,75 @@

import { FireTypes } from './firestore';
import type { $allow, $docLabel, $functions, $schema } from './utils';
import { FireTypes } from './firestore'
import type { $allow, $docLabel, $functions, $schema } from './utils'
export declare const allowOptions: {
read: {
read: null;
get: null;
list: null;
};
write: {
write: null;
create: null;
update: null;
delete: null;
};
};
read: {
read: null
get: null
list: null
}
write: {
write: null
create: null
update: null
delete: null
}
}
export declare namespace Fireschema {
type ConditionExp = string | true;
type DataSchemaOptions<T> = {
[K in keyof T]: T[K] extends null ? 'null' : T[K] extends string ? 'string' : T[K] extends string | null ? 'string | null' : T[K] extends number ? 'int' | 'float' : T[K] extends number | null ? 'int' | 'float | null' : T[K] extends boolean ? 'bool' : T[K] extends boolean | null ? 'bool | null' : T[K] extends FireTypes.Timestamp ? 'timestamp' : T[K] extends FireTypes.Timestamp | null ? 'timestamp | null' : T[K] extends any[] ? 'list' : T[K] extends any[] | null ? 'list | null' : T[K] extends {} ? 'map' : T[K] extends {} | null ? 'map | null' : never;
};
type FunctionsOptions = {
[key: string]: string;
};
namespace RootOptions {
type Meta = {
[$functions]: FunctionsOptions;
};
type Children = {
[K in string]: CollectionOptions.All;
};
type All = Meta & Children;
type ConditionExp = string | true
type DataSchemaOptions<T> = {
[K in keyof T]: T[K] extends null
? 'null'
: T[K] extends string
? 'string'
: T[K] extends string | null
? 'string | null'
: T[K] extends number
? 'int' | 'float'
: T[K] extends number | null
? 'int' | 'float | null'
: T[K] extends boolean
? 'bool'
: T[K] extends boolean | null
? 'bool | null'
: T[K] extends FireTypes.Timestamp
? 'timestamp'
: T[K] extends FireTypes.Timestamp | null
? 'timestamp | null'
: T[K] extends any[]
? 'list'
: T[K] extends any[] | null
? 'list | null'
: T[K] extends {}
? 'map'
: T[K] extends {} | null
? 'map | null'
: never
}
type FunctionsOptions = {
[key: string]: string
}
namespace RootOptions {
type Meta = {
[$functions]: FunctionsOptions
}
type AllowOptions = {
[K in keyof (typeof allowOptions.read & typeof allowOptions.write)]+?: string | true;
};
namespace CollectionOptions {
type Meta = {
[$schema]: DataSchemaOptions<any> | DataSchemaOptions<any>[];
[$docLabel]: string;
[$allow]: AllowOptions;
};
type Children = {
[K in string]: Meta & Children;
};
type All = Meta & Children;
type Children = {
[K in string]: CollectionOptions.All
}
type All = Meta & Children
}
type AllowOptions = {
[K in keyof (typeof allowOptions.read & typeof allowOptions.write)]+?:
| string
| true
}
namespace CollectionOptions {
type Meta = {
[$schema]: DataSchemaOptions<any> | DataSchemaOptions<any>[]
[$docLabel]: string
[$allow]: AllowOptions
}
type Children = {
[K in string]: Meta & Children
}
type All = Meta & Children
}
}

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

import { Fireschema } from './types';
export declare const $functions: unique symbol;
export declare const $schema: unique symbol;
export declare const $docLabel: unique symbol;
export declare const $allow: unique symbol;
export declare const $or: (conditions: Fireschema.ConditionExp[]) => string;
export declare const $and: (conditions: Fireschema.ConditionExp[]) => string;
import { Fireschema } from './types'
export declare const $functions: unique symbol
export declare const $schema: unique symbol
export declare const $docLabel: unique symbol
export declare const $allow: unique symbol
export declare const $or: (conditions: Fireschema.ConditionExp[]) => string
export declare const $and: (conditions: Fireschema.ConditionExp[]) => string
{
"name": "fireschema",
"version": "0.0.1",
"version": "0.1.0",
"repository": "github:yarnaimo/fireschema",

@@ -8,2 +8,3 @@ "license": "MIT",

"main": "dist/index.js",
"bin": "src/bin/cli.ts",
"scripts": {

@@ -14,2 +15,3 @@ "build": "tsc",

"prepare": "yarn build",
"serve": "firebase emulators:start --only firestore",
"start": "NODE_ENV=production node dist/index.js",

@@ -26,7 +28,9 @@ "test": "NODE_ENV=test jest",

"devDependencies": {
"@firebase/testing": "^0.20.9",
"@yarnaimo/eslint-config": "^0.0.4",
"@yarnaimo/tss": "^0.3.2",
"firebase": "^7.16.1",
"firebase-admin": "^9.0.0"
"firebase-admin": "^9.0.0",
"typescript": "^4.0.0-beta"
}
}

@@ -1,4 +0,5 @@

export * from './fireschema'
export * from './firestore'
export * from './constants'
export * from './controller'
export * from './factories'
export * from './types'
export * from './utils'
import is from '@sindresorhus/is' // eslint-disable-line
import type * as Type from 'type-fest' // eslint-disable-line
export { is }
export type { Type }
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