diff --git a/.gitignore b/.gitignore index e9dbaca..a8e1f67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules +package-lock.json +dist certs -package-lock.json *.env -package-lock.json +*.tsbuildinfo diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..ba7d899 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +examples +node_modules +pkg diff --git a/examples/main.ts b/examples/main.ts index 6037b85..aee27fa 100644 --- a/examples/main.ts +++ b/examples/main.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import MongoAssert from '..'; import dotenv from 'dotenv'; import path from 'path'; -import { createMongoClient, ObjectId } from '../lib/mongodb'; +import { createMongoClient, ObjectId } from '../pkg/lib/mongodb'; dotenv.config(); diff --git a/package.json b/package.json index d069c3c..f609b5a 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "mongo-assert", - "version": "1.0.0", + "version": "0.0.1", "description": "", "main": "index.ts", "scripts": { + "build": "tsc", "start": "ts-node index.ts", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/actions/constrained.ts b/pkg/actions/constrained.ts similarity index 100% rename from actions/constrained.ts rename to pkg/actions/constrained.ts diff --git a/actions/relation.ts b/pkg/actions/relation.ts similarity index 100% rename from actions/relation.ts rename to pkg/actions/relation.ts diff --git a/actions/unique.ts b/pkg/actions/unique.ts similarity index 100% rename from actions/unique.ts rename to pkg/actions/unique.ts diff --git a/index.ts b/pkg/index.ts similarity index 100% rename from index.ts rename to pkg/index.ts diff --git a/lib/mongodb.ts b/pkg/lib/mongodb.ts similarity index 84% rename from lib/mongodb.ts rename to pkg/lib/mongodb.ts index 0e8abc4..0ca14d8 100644 --- a/lib/mongodb.ts +++ b/pkg/lib/mongodb.ts @@ -1,4 +1,4 @@ -import { MongoClient, MongoClientOptions } from "mongodb"; +import { MongoClient, type MongoClientOptions } from "mongodb"; import { z } from "zod"; // mongodb ObjectId as zod schema (we'll settle on our definition later) diff --git a/lib/types.ts b/pkg/lib/types.ts similarity index 100% rename from lib/types.ts rename to pkg/lib/types.ts diff --git a/tsconfig.json b/tsconfig.json index e075f97..c40c24f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ /* Projects */ + "incremental": true, // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ @@ -25,7 +26,10 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ + "module": "ESNext", + "rootDir": "./pkg", + "moduleResolution": "Bundler", + // "module": "commonjs", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ @@ -49,6 +53,11 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ /* Emit */ + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./dist", + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ @@ -74,16 +83,17 @@ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ /* Interop Constraints */ + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "strict": true, + "noImplicitAny": true, // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ @@ -105,5 +115,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } + }, + "include": ["./pkg/**/*"], + "exclude": ["node_modules", "dist"] }