@decaf-ts/core 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&("get"in i?r.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){e[o=void 0===o?t:o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.VERSION=void 0,__exportStar(require("./identity/index.cjs"),exports),__exportStar(require("./interfaces/index.cjs"),exports),__exportStar(require("./model/index.cjs"),exports),__exportStar(require("./persistence/index.cjs"),exports),__exportStar(require("./repository/index.cjs"),exports),exports.VERSION="0.0.3";
1
+ var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&("get"in i?r.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){e[o=void 0===o?t:o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.VERSION=void 0,__exportStar(require("./identity/index.cjs"),exports),__exportStar(require("./interfaces/index.cjs"),exports),__exportStar(require("./model/index.cjs"),exports),__exportStar(require("./persistence/index.cjs"),exports),__exportStar(require("./repository/index.cjs"),exports),exports.VERSION="0.0.4";
package/lib/index.d.ts CHANGED
@@ -20,4 +20,4 @@ export * from "./repository";
20
20
  * @const VERSION
21
21
  * @memberOf module:ts-workspace
22
22
  */
23
- export declare const VERSION = "0.0.3";
23
+ export declare const VERSION = "0.0.4";
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.index=index,exports.uniqueOnCreateUpdate=uniqueOnCreateUpdate,exports.unique=unique;let db_decorators_1=require("@decaf-ts/db-decorators"),reflection_1=require("@decaf-ts/reflection"),constants_1=require("../persistence/constants.cjs");function index(e,t){return(0,reflection_1.metadata)((0,db_decorators_1.getDBKey)(""+constants_1.PersistenceKeys.INDEX+(e&&e.length?"."+e.join("."):"")),{directions:t,compositions:e})}async function uniqueOnCreateUpdate(e,t,r){if(r[t]){try{await this.read(r[t])}catch(e){if(e instanceof db_decorators_1.NotFoundError)return}throw new db_decorators_1.ConflictError(`model already exists with ${t} equal to `+JSON.stringify(r[t],void 0,2))}}function unique(){return(0,reflection_1.apply)((0,db_decorators_1.onCreateUpdate)(uniqueOnCreateUpdate),(0,reflection_1.metadata)((0,db_decorators_1.getDBKey)(constants_1.PersistenceKeys.UNIQUE),{}))}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @summary Index Decorator
3
+ * @description properties decorated will the index in the
4
+ * DB for performance in queries
5
+ *
6
+ * @param {OrderDirection[]} [directions]
7
+ * @param {string[]} [compositions]
8
+ *
9
+ * @function index
10
+ */ import { DBModel, IRepository } from "@decaf-ts/db-decorators";
11
+ import { OrderDirection } from "../repository/constants";
12
+ export declare function index(compositions?: string[], directions?: OrderDirection[]): import("@decaf-ts/reflection").CustomDecorator<V>;
13
+ export declare function uniqueOnCreateUpdate<T extends DBModel, V extends IRepository<T>, Y = any>(this: V, data: Y, key: string, model: T): Promise<void>;
14
+ /**
15
+ * @summary Unique Decorator
16
+ * @description Tags a property as unique.
17
+ * No other elements in that table can have the same property value
18
+ *
19
+ * @function unique
20
+ *
21
+ * @memberOf module:wallet-db.Decorators
22
+ */
23
+ export declare function unique(): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.PersistenceKeys=void 0,exports.PersistenceKeys={REFLECT:"model.persistence.",ADAPTER:"adapter",INJECTABLE:"decaf-adapter-{0}"};
1
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.PersistenceKeys=void 0,exports.PersistenceKeys={REFLECT:"model.persistence.",INDEX:"index",UNIQUE:"unique",ADAPTER:"adapter",INJECTABLE:"decaf-adapter-{0}"};
@@ -0,0 +1 @@
1
+ var OrderDirection,Cascade;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DefaultCascade=exports.Cascade=exports.OrderDirection=void 0,(e=>{e.ASC="asc",e.DSC="desc"})(OrderDirection||(exports.OrderDirection=OrderDirection={})),(e=>{e.CASCADE="cascade",e.NONE="none"})(Cascade||(exports.Cascade=Cascade={})),exports.DefaultCascade={update:Cascade.CASCADE,delete:Cascade.NONE};
@@ -0,0 +1,25 @@
1
+ import { CascadeMetadata } from "./types";
2
+ /**
3
+ * @summary defines order directions when sorting
4
+ *
5
+ * @constant OrderDirection
6
+ *
7
+ * @category Query
8
+ */
9
+ export declare enum OrderDirection {
10
+ /**
11
+ * @summary Defines the sort order as ascending
12
+ * @prop ASC
13
+ */
14
+ ASC = "asc",
15
+ /**
16
+ * @summary Defines the sort order as descending
17
+ * @property {string} DSC
18
+ */
19
+ DSC = "desc"
20
+ }
21
+ export declare enum Cascade {
22
+ CASCADE = "cascade",
23
+ NONE = "none"
24
+ }
25
+ export declare const DefaultCascade: CascadeMetadata;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,12 @@
1
+ import { Cascade, OrderDirection } from "./constants";
2
+ /**
3
+ * @summary defines the cascading behaviour
4
+ */
5
+ export type CascadeMetadata = {
6
+ update: Cascade;
7
+ delete: Cascade;
8
+ };
9
+ export type IndexMetadata = {
10
+ directions?: OrderDirection[2];
11
+ compositions?: string[];
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/core",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "template for ts projects",
5
5
  "type": "module",
6
6
  "exports": {