Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ jobs:
- run:
name: Configure NPM repository access
command: sed -i -e "s|\${GITHUB_PERSONAL_ACCESS_TOKEN}|$GITHUB_PERSONAL_ACCESS_TOKEN|g" npmrc-env && mv npmrc-env .npmrc

- restore_cache:
key: v1-dep-{{ .Branch }}-{{ checksum "package.json" }}
key: v1-dep-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- run:
name: Run npm ci
command: npm ci
name: Install node dependencies
command: |
if [[ ! -d node_modules ]]; then
npm ci --loglevel warn --yes
else
echo "package.json and package-lock.json unchanged. Using cache."
fi
- save_cache:
key: v1-dep-{{ .Branch }}-{{ checksum "package.json" }}
key: v1-dep-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- node_modules

Expand Down
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"json",
"document"
],
"types": "./types/index.d.ts",
"main": "./lib/ottoman",
"license": "Apache2",
"name": "@etops/ottoman",
"scripts": {
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -- test/*.test.js",
"lint": "eslint ./lib"
"lint": "eslint ./lib",
"regen-types": "tsc"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
Expand All @@ -32,11 +34,12 @@
"ink-docstrap": "git+https://github.com/brett19/docstrap.git#master",
"istanbul": "~0.4.5",
"jsdoc": "~3.3.0-alpha9",
"mocha": "~5.2.0"
"mocha": "~5.2.0",
"typescript": "4.0.2"
},
"repository": {
"type": "git",
"url": "http://github.com/etops/node-ottoman.git"
},
"version": "1.0.8"
"version": "1.0.9"
}
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"include": [
"./lib"
],
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types"
}
}
2 changes: 2 additions & 0 deletions types/autofns.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function autogenUuid(): any;
export { autogenUuid as uuid };
45 changes: 45 additions & 0 deletions types/cbstoreadapter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export = CbStoreAdapter;
/**
* The Couchbase store adapter implements an Ottoman StoreAdapter suitable
* for using Ottoman with Couchbase Server.
* @param bucket
* @constructor
*/
declare function CbStoreAdapter(bucket: any, cb: any): void;
declare class CbStoreAdapter {
/**
* The Couchbase store adapter implements an Ottoman StoreAdapter suitable
* for using Ottoman with Couchbase Server.
* @param bucket
* @constructor
*/
constructor(bucket: any, cb: any);
couchbase: any;
bucket: any;
ddocs: {};
gsis: {};
debug: boolean;
isNotFoundError(err: any): boolean;
get(key: string, callback: any): void;
store(key: string, data: any, cas: any, callback: any): void;
remove(key: any, cas: any, callback: any): void;
private _createViewIndex;
private _createN1qlIndex;
createIndex(type: string, modelName: string, name: string, fields: string[], callback: any): void;
private _ensureMrIndices;
private _ensureGsiIndices;
ensureIndices(callback: any): void;
private _searchViewIndex;
private _searchN1qlIndex;
searchIndex(type: string, modelName: string, name: string, options: any, callback: any): void;
count(type: string, modelName: string, options: {
filter: any;
}, callback: any): void;
find(type: string, modelName: string, options: {
filter: any;
limit: number;
skip: number;
sort: string | string[];
namespace: string;
}, callback: any): void;
}
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ottoman from "./ottoman";

// based on https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
// to get a head start with the typing and not to deviate from original ottoman v1
declare module "@etops/ottoman" {
export default ottoman;
}
17 changes: 17 additions & 0 deletions types/mockstoreadapter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export = MockStoreAdapter;
declare function MockStoreAdapter(): void;
declare class MockStoreAdapter {
data: {};
indexes: {};
debug: boolean;
clear(): void;
isNotFoundError(err: any): boolean;
get(key: any, callback: any): void;
store(key: any, data: any, cas: any, callback: any): void;
remove(key: any, cas: any, callback: any): void;
createIndex(type: any, modelName: any, name: any, fields: any, callback: any): void;
ensureIndices(callback: any): void;
searchIndex(type: any, modelName: any, name: any, options: any, callback: any): void;
count(type: any, modelName: any, options: any, callback: any): void;
find(type: any, modelName: any, options: any, callback: any): void;
}
44 changes: 44 additions & 0 deletions types/modelinstance.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export = ModelInstance;
/**
* Constructs a new model instance and for models with a default constructor,
* applies the data in object passed to the instance.
*
* @param {Object} data
* @constructor
*/
declare function ModelInstance(...args: any[]): void;
declare class ModelInstance {
/**
* Constructs a new model instance and for models with a default constructor,
* applies the data in object passed to the instance.
*
* @param {Object} data
* @constructor
*/
constructor(...args: any[]);
$: {};
loaded(): boolean;
id(): string;
private _toCoo;
toCoo(): any;
toJSON(): any;
private inspect;
save(callback: Function): void;
load(...args: any[]): void;
remove(callback: Function): void;
}
declare namespace ModelInstance {
function fromData(data: any): ModelInstance;
function applyData(mdlInst: ModelInstance, data: any): void;
function create(data: any, callback: Function, ...args: any[]): void;
function namePath(typeOnly: any): string;
function loadAll(items: ModelInstance[], callback: Function): void;
function find(filter: any, options?: any, callback: Function): void;
function count(filter: any, options?: any, callback: Function): void;
function getById(id: string, options: any, callback: Function): void;
function refByKey(key: string): ModelInstance;
function plugin(pluginFn: any, options: any): ModelInstance;
function ref(id: string): ModelInstance;
function pre(event: "load" | "validate" | "save" | "remove", handler: Function): any;
function post(event: "load" | "validate" | "save" | "remove", fn: Function): any;
}
71 changes: 71 additions & 0 deletions types/ottoman.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
export = ottoman;
declare var ottoman: Ottoman;
/**
* The core manager class for the ODM.
*
* @constructor
*/
declare function Ottoman(options: any): void;
declare class Ottoman {
/**
* The core manager class for the ODM.
*
* @constructor
*/
constructor(options: any);
namespace: any;
store: any;
models: any;
types: any;
delayedBind: {};
plugins: any[];
bucket: any;
plugin(pluginFn: any, options: any): Ottoman;
nsPrefix(): string;
isTypeDef(type: any): boolean;
isModel(model: any): boolean;
typeByName(type: string): import("./modelinstance") | TypeDef | any;
typeByNameAndNamespace(type: string, namespace: string): import("./modelinstance") | TypeDef | any;
private _parseFieldType;
private _makeField;
private _createSchema;
private _findModelsByRefDocIndex;
private _findModelsByDefIndex;
private _findModelByIndex;
private _countModels;
private _normFilter;
private _findModels;
private _findModelsByQuery;
private _buildModel;
private _delayBind;
private _buildAndRegisterModel;
_applyPlugins(model: any): Ottoman;
private _buildAndRegisterTypeDef;
type(name: string, options: any): TypeDef;
model(name: string, schemaDef: any, options: {
index: any;
queries: any;
id: string;
store: import("./storeadapter");
}): any;
validate(mdlInst: import("./modelinstance"), callback: any): void;
_ensureModelIndices(model: any, callback: any): void;
ensureIndices(callback: Function): void;
getModel(name: string, prefixed: boolean): any;
fromCoo(data: any, type: string): import("./modelinstance");
toCoo(obj: import("./modelinstance")): any;
}
declare namespace Ottoman {
const loadAll: (items: import("./modelinstance")[], callback: Function) => void;
}
/**
* The data definition for a typedef object. Typedef's are
* simply aliases for other types.
*
* @constructor
* @private
* @ignore
*/
declare function TypeDef(): void;
declare class TypeDef {
}
4 changes: 4 additions & 0 deletions types/ottopath.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function parse(pathStr: any): any;
export function query(pathObj: any, value: any): void;
export function stringifyExpression(exprObj: any): any;
export function stringify(pathObj: any): string;
Loading