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

fire-entity

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fire-entity - npm Package Compare versions

Comparing version 0.7.2 to 0.8.0

10

lib/entity.d.ts
export interface FireEntityProps {
id: string;
type: string;
entityType: string;
path: string;

@@ -11,7 +11,4 @@ parentPath?: string;

}
export declare type FireEntityInsert<T extends FireEntity> = Omit<T, keyof FireEntity> & {
type: string;
parentPath?: string;
owner?: string;
};
declare type InsertProps = Pick<FireEntity, 'owner' | 'parentPath' | 'entityType'>;
export declare type FireEntityInsert<T extends FireEntity> = Omit<T, keyof FireEntity> & InsertProps;
export declare const EntityAttributes: string[];

@@ -21,1 +18,2 @@ export declare function prepareTransaction(entityData: {

}): {};
export {};

8

lib/entity.js

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

export const EntityAttributes = ['id', 'type', 'path', 'parentPath', 'owner'];
export const EntityAttributes = [
'id',
'entityType',
'path',
'parentPath',
'owner',
];
export function prepareTransaction(entityData) {

@@ -3,0 +9,0 @@ entityData = Object.assign(Object.assign({}, entityData), { lastUpdated: new Date() });

@@ -12,3 +12,3 @@ import 'firebase/firestore';

id: snap.id,
type: snap.ref.parent.id,
entityType: snap.ref.parent.id,
path: snap.ref.path,

@@ -15,0 +15,0 @@ parentPath: snap.ref.parent.parent

@@ -6,6 +6,4 @@ import { __awaiter, __rest } from "tslib";

import { buildQuery } from './query';
function getCollectionPath(entity) {
return !entity.parentPath
? entity.type
: `${entity.parentPath}/${entity.type}`;
function getCollectionPath({ entityType, parentPath, }) {
return !parentPath ? entityType : `${parentPath}/${entityType}`;
}

@@ -19,3 +17,3 @@ export class EntityFirestore {

return __awaiter(this, void 0, void 0, function* () {
const { type, parentPath } = insert, data = __rest(insert, ["type", "parentPath"]);
const { entityType, parentPath } = insert, data = __rest(insert, ["entityType", "parentPath"]);
const preparedData = prepareTransaction(data);

@@ -22,0 +20,0 @@ if (this.config.setOwner) {

{
"name": "fire-entity",
"version": "0.7.2",
"version": "0.8.0",
"description": "Allows for storing and retrieving documents in a standardized format from Firestore.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -12,3 +12,3 @@ /**

*/
type: string;
entityType: string;
/**

@@ -38,15 +38,17 @@ * The path to this entity within the database.

type InsertProps = Pick<FireEntity, 'owner' | 'parentPath' | 'entityType'>;
/**
* An interface representing the necessary information for inserting an entity usign this library.
*/
export type FireEntityInsert<T extends FireEntity> = Omit<
T,
keyof FireEntity
> & {
type: string;
parentPath?: string;
owner?: string;
};
export type FireEntityInsert<T extends FireEntity> = Omit<T, keyof FireEntity> &
InsertProps;
export const EntityAttributes = ['id', 'type', 'path', 'parentPath', 'owner'];
export const EntityAttributes = [
'id',
'entityType',
'path',
'parentPath',
'owner',
];

@@ -53,0 +55,0 @@ export function prepareTransaction(entityData: { [key: string]: any }): {} {

@@ -19,3 +19,3 @@ import { FireEntity, FireEntityProps } from '../entity';

id: snap.id,
type: snap.ref.parent.id,
entityType: snap.ref.parent.id,
path: snap.ref.path,

@@ -22,0 +22,0 @@

@@ -10,8 +10,7 @@ import { firestore } from 'firebase/app';

function getCollectionPath<T extends FireEntity, E extends FireEntity>(
entity: T | FireEntityInsert<E>
): string {
return !entity.parentPath
? entity.type
: `${entity.parentPath}/${entity.type}`;
function getCollectionPath<T extends FireEntity, E extends FireEntity>({
entityType,
parentPath,
}: T | FireEntityInsert<E>): string {
return !parentPath ? entityType : `${parentPath}/${entityType}`;
}

@@ -31,3 +30,3 @@

): Promise<void> {
const { type, parentPath, ...data } = insert;
const { entityType, parentPath, ...data } = insert;
const preparedData = prepareTransaction(data) as T;

@@ -34,0 +33,0 @@ if (this.config.setOwner) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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