diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 94081c1..97a532b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -42,6 +42,9 @@ jobs: - name: Install dependencies run: npm ci + - name: Compile package + run: npm run compile + # ref: https://github.community/t/auto-update-package-json-on-publishing/16894 - name: Update source code run: | diff --git a/.gitignore b/.gitignore index 7aa77ae..6c97830 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ node_modules/ .history .idea + +# Ignore build files +build/ diff --git a/README.md b/README.md index 7bc09de..6ab22fb 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ g) Entity types belong in the projects that interface with their data layers. Fo ## Documentation The `index.d.ts` file should serve as a self documenting file. Alternatively, [Typedoc](https://typedoc.org/) could be used however it would require a build step which it mostly unnecessary for this project. That said, if for any reason we would like to go with a full ts build step then Typedocs would be a great way to create external documentation that can be served via this repo's Github Pages. +The **constants** or other types which needs be compiled must be added in a separate file `constants.ts` where the same should be imported as `@unumid/core-types/constants` + ## Release Releases and publishing to NPM is automated via Github Actions CI job. In order to trigger a release one should push a git tag with a preceding `v` with semver notation, ie `v1.1.1`, to the `main` branch. This will trigger the CI job to bump the package version, make a release commit, and make a Github Release. The contents of the Github Release are autogenerated based on pull requests with commits associated with the release, so please use PRs to makes changes to `main`. The message of the git tag will be the commit message for the release so please make it meaningful. For example, `git tag v1.1.1 -m "Updated project with a new CI job" && git push origin v1.1.1 && git tag -d v1.1.1`. diff --git a/enums.ts b/enums.ts new file mode 100644 index 0000000..14786b9 --- /dev/null +++ b/enums.ts @@ -0,0 +1,8 @@ +/** + * Type of possible options for mandatory field a credential request. + */ +export const MandatoryEnum = { + YES: 'yes', + NO: 'no', + IF_AVAILABLE: 'if_available' +} as const diff --git a/index.d.ts b/index.d.ts index 0159006..d4bb66c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,5 @@ +import { MandatoryEnum } from './enums'; + /**************************************** * DATA RESOLVER TYPES * * TYPES FROM THE DATA RESOLVER SERVICE * @@ -93,15 +95,6 @@ export interface AuthenticationResult { user: UserDto; } -/** - * Type of possible options for mandatory field a credential request. - */ -export enum MandatoryEnum { - YES = 'yes', - NO = 'no', - IF_AVAILABLE = 'if_available' -} - /** * Represents a credential request in a presentation request */ diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..f171790 --- /dev/null +++ b/index.ts @@ -0,0 +1 @@ +export * as enums from './enums' diff --git a/package-lock.json b/package-lock.json index e197e85..866f56e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@unumid/core-types", - "version": "0.12.2", + "version": "0.23.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@unumid/core-types", - "version": "0.12.2", + "version": "0.23.2", "license": "ISC", "devDependencies": { "typescript": "^4.9.5" diff --git a/package.json b/package.json index efe15f8..9459f5e 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,16 @@ { "name": "@unumid/core-types", - "version": "0.23.1", + "version": "0.23.2", "description": "UnumID shared core service types", - "main": "index.js", + "main": "build/index.js", + "types": "build/index.d.ts", "engines": { "node": ">= 18.12.1", "npm": ">=8.19.2" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "tsc --build" }, "repository": { "type": "git", @@ -22,5 +24,6 @@ "homepage": "https://github.com/UnumID/core-types#readme", "devDependencies": { "typescript": "^4.9.5" - } + }, + "files": ["build/"] } diff --git a/tsconfig.json b/tsconfig.json index 59e7beb..8595931 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "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'. */ @@ -15,7 +15,7 @@ "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./build", /* Redirect output structure to the directory. */ - "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + "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. */ @@ -23,7 +23,7 @@ // "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. */ @@ -33,13 +33,13 @@ // "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. */ - + /* 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. */ @@ -51,17 +51,17 @@ "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. */ @@ -72,4 +72,3 @@ "test" ] } - \ No newline at end of file