Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
samuk190 committed Jun 25, 2024
2 parents 1ce0784 + 708328b commit 5fb89d6
Show file tree
Hide file tree
Showing 23 changed files with 246 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/npm-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 2 additions & 0 deletions dist/localbase.dev.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _exports: any;
export = _exports;
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default Localbase;
import Localbase from "./localbase/localbase";
1 change: 1 addition & 0 deletions localbase/api-utils/error.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function error(message: any): string;
9 changes: 9 additions & 0 deletions localbase/api-utils/reset.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function reset(): void;
export default class reset {
collectionName: any;
orderByProperty: any;
orderByDirection: any;
limitBy: any;
docSelectionCriteria: any;
userErrors: any[];
}
1 change: 1 addition & 0 deletions localbase/api-utils/selectionLevel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function selectionLevel(): string | undefined;
1 change: 1 addition & 0 deletions localbase/api-utils/showUserErrors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function showUserErrors(): void;
5 changes: 5 additions & 0 deletions localbase/api-utils/success.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function success(message: any, data: any): {
success: boolean;
message: any;
data: any;
};
1 change: 1 addition & 0 deletions localbase/api/actions/add.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function add(data: { [key:string]: any }, keyProvided: string): void ;
11 changes: 11 additions & 0 deletions localbase/api/actions/delete.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function deleteIt(): any;
export default class deleteIt {
deleteDatabase: () => void;
deleteCollection: () => void;
addToDeleteCollectionQueue: (collectionName: any) => void;
runDeleteCollectionQueue: () => void;
deleteNextCollectionFromQueue: any;
deleteDocument: () => void;
deleteDocumentByCriteria: () => void;
deleteDocumentByKey: () => void;
}
12 changes: 12 additions & 0 deletions localbase/api/actions/get.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function get(options?: {
keys: boolean;
}): any;
export default class get {
constructor(options?: {
keys: boolean;
});
getCollection: () => any;
getDocument: () => any;
getDocumentByCriteria: () => any;
getDocumentByKey: () => any;
}
2 changes: 2 additions & 0 deletions localbase/api/actions/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ export default function get(options = { keys: false }) {
logMessage += `, ordered by "${ orderByProperty }"`
if (!options.keys) {
collection.sort((a, b) => {
if (!a.hasOwnProperty(orderByProperty) || !b.hasOwnProperty(orderByProperty)) return 0
return a[orderByProperty].toString().localeCompare(b[orderByProperty].toString())
})
}
else {
collection.sort((a, b) => {
if (!a.hasOwnProperty(orderByProperty) || !b.hasOwnProperty(orderByProperty)) return 0
return a.data[orderByProperty].toString().localeCompare(b.data[orderByProperty].toString())
})
}
Expand Down
12 changes: 12 additions & 0 deletions localbase/api/actions/set.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function set(newDocument: any, options?: {
keys: boolean;
}): any;
export default class set {
constructor(newDocument: any, options?: {
keys: boolean;
});
setCollection: () => void;
setDocument: () => void;
setDocumentByCriteria: () => void;
setDocumentByKey: () => void;
}
6 changes: 6 additions & 0 deletions localbase/api/actions/update.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function update(docUpdates: any): any;
export default class update {
constructor(docUpdates: any);
updateDocumentByCriteria: () => void;
updateDocumentByKey: () => void;
}
5 changes: 5 additions & 0 deletions localbase/api/filters/limit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function limit(limitBy: any): this;
export default class limit {
constructor(limitBy: any);
limitBy: any;
}
6 changes: 6 additions & 0 deletions localbase/api/filters/orderBy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function orderBy(property: any, direction: any): this;
export default class orderBy {
constructor(property: any, direction: any);
orderByProperty: string | undefined;
orderByDirection: any;
}
5 changes: 5 additions & 0 deletions localbase/api/selectors/collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function collection(collectionName: any): this;
export default class collection {
constructor(collectionName: any);
collectionName: string | undefined;
}
5 changes: 5 additions & 0 deletions localbase/api/selectors/doc.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function doc(docSelectionCriteria: any): this;
export default class doc {
constructor(docSelectionCriteria: any);
docSelectionCriteria: any;
}
36 changes: 36 additions & 0 deletions localbase/localbase.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export default class Localbase {
constructor(dbName: any);
dbName: any;
lf: {};
collectionName: any;
orderByProperty: any;
orderByDirection: any;
limitBy: any;
docSelectionCriteria: any;
deleteCollectionQueue: {
queue: never[];
running: boolean;
};
config: {
debug: boolean;
};
userErrors: any[];
collection: typeof collection;
doc: typeof doc;
orderBy: typeof orderBy;
limit: typeof limit;
get: typeof get;
add: typeof add;
update: typeof update;
set: typeof set;
delete: typeof deleteIt;
}
import collection from "./api/selectors/collection";
import doc from "./api/selectors/doc";
import orderBy from "./api/filters/orderBy";
import limit from "./api/filters/limit";
import get from "./api/actions/get";
import add from "./api/actions/add";
import update from "./api/actions/update";
import set from "./api/actions/set";
import deleteIt from "./api/actions/delete";
1 change: 1 addition & 0 deletions localbase/utils/isSubset.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function isSubset(superObj: any, subObj: any): any;
15 changes: 15 additions & 0 deletions localbase/utils/logger.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default logger;
declare namespace logger {
const baseStyle: string;
namespace colors {
const log: string;
const error: string;
const warn: string;
}
function log(message: any, secondary: any): void;
function log(message: any, secondary: any): void;
function error(message: any, secondary: any): void;
function error(message: any, secondary: any): void;
function warn(message: any, secondary: any): void;
function warn(message: any, secondary: any): void;
}
1 change: 1 addition & 0 deletions localbase/utils/updateObject.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function updateObject(obj: any, ...args: any[]): any;
71 changes: 71 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"allowJs": true, /* Allow javascript files to be compiled. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"emitDeclarationOnly": true, /* Generate ONLY '.d.ts' file, no output javascript */
// "lib": [], /* Specify library files to be included in the compilation. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}

0 comments on commit 5fb89d6

Please sign in to comment.