ozone-type
Advanced tools
Comparing version 4.1.3-alpha.5 to 4.1.3-alpha.6
@@ -49,7 +49,6 @@ export declare type UUID = string; | ||
}; | ||
export declare type Patch<T> = { | ||
export declare type Patch<T extends Item> = { | ||
[P in keyof T]?: T[P] | null; | ||
}; | ||
export declare class Item { | ||
constructor(src?: Item); | ||
id?: UUID; | ||
@@ -65,2 +64,3 @@ version?: UUID; | ||
modificationUser?: UUID; | ||
constructor(src?: Item); | ||
} | ||
@@ -67,0 +67,0 @@ export declare class GenericItem extends Item { |
@@ -55,2 +55,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
export { Item }; | ||
function toPatch(item) { | ||
let patch = {}; | ||
for (let prop of Object.getOwnPropertyNames(item)) { | ||
const val = item[prop]; | ||
if (val !== undefined) { | ||
patch[prop] = val; | ||
} | ||
} | ||
return patch; | ||
} | ||
function toPatchWithUndefinedAsNull(item) { | ||
let patch = {}; | ||
for (let prop of Object.getOwnPropertyNames(item)) { | ||
const val = item[prop]; | ||
if (val === undefined) { | ||
patch[prop] = null; | ||
} | ||
else { | ||
patch[prop] = val; | ||
} | ||
} | ||
return patch; | ||
} | ||
export class GenericItem extends Item { | ||
@@ -57,0 +80,0 @@ } |
@@ -42,3 +42,5 @@ export type UUID = string | ||
export type Patch<T> = { | ||
type nullablePatchProps<T extends Item> = keyof T | ||
export type Patch<T extends Item> = { | ||
[P in keyof T]?: T[P] | null; | ||
@@ -49,2 +51,13 @@ } | ||
export class Item { | ||
id?: UUID | ||
version?: UUID | ||
type?:string | ||
_meta?: ItemMeta | ||
name?: string | ||
deleted?: boolean | ||
traits?: string[] | ||
tenant?: UUID | ||
creationUser?: UUID | ||
modificationUser?: UUID | ||
constructor (src?: Item) { | ||
@@ -64,15 +77,28 @@ if (src) { | ||
} | ||
} | ||
id?: UUID | ||
version?: UUID | ||
type?:string | ||
_meta?: ItemMeta | ||
name?: string | ||
deleted?: boolean | ||
traits?: string[] | ||
tenant?: UUID | ||
creationUser?: UUID | ||
modificationUser?: UUID | ||
function toPatch<T extends Item>(item:T): Patch<T> { | ||
let patch : any = {} | ||
for (let prop of Object.getOwnPropertyNames(item)) { | ||
const val:any|undefined|null = (item as any)[prop] | ||
if (val !== undefined) { | ||
patch[prop] = val | ||
} | ||
} | ||
return patch as Patch<T> | ||
} | ||
function toPatchWithUndefinedAsNull<T extends Item>(item:T): Patch<T> { | ||
let patch : any = {} | ||
for (let prop of Object.getOwnPropertyNames(item)) { | ||
const val:any|undefined|null = (item as any)[prop] | ||
if (val === undefined) { | ||
patch[prop] = null | ||
} else { | ||
patch[prop] = val | ||
} | ||
} | ||
return patch as Patch<T> | ||
} | ||
export class GenericItem extends Item { | ||
@@ -79,0 +105,0 @@ [key: string]: any; |
{ | ||
"name": "ozone-type", | ||
"version": "4.1.3-alpha.5", | ||
"version": "4.1.3-alpha.6", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
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
2168008
28439