From 1cd854f4ec85056772f9ef2ad9736812539d8a1b Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Thu, 10 Aug 2023 17:32:54 -0300 Subject: [PATCH 01/12] fix: replace enum to constant --- index.d.ts | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 0159006..3bb1ae6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -96,11 +96,11 @@ export interface AuthenticationResult { /** * Type of possible options for mandatory field a credential request. */ -export enum MandatoryEnum { +export const MandatoryEnum = { YES = 'yes', NO = 'no', IF_AVAILABLE = 'if_available' -} +} as const /** * Represents a credential request in a presentation request diff --git a/package.json b/package.json index efe15f8..84be8e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@unumid/core-types", - "version": "0.23.1", + "version": "0.23.2", "description": "UnumID shared core service types", "main": "index.js", "engines": { From 96450825162d7c54034a4e4f5f03b2955838dc71 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Thu, 10 Aug 2023 17:35:50 -0300 Subject: [PATCH 02/12] refactor: point main to index.d.ts --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 84be8e2..a6fa043 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@unumid/core-types", "version": "0.23.2", "description": "UnumID shared core service types", - "main": "index.js", + "main": "index.d.ts", "engines": { "node": ">= 18.12.1", "npm": ">=8.19.2" From 5984dcd8dba6f49ce4a3e95642d50f653ef5bd73 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Thu, 10 Aug 2023 17:40:14 -0300 Subject: [PATCH 03/12] fix: remove enum syntax --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3bb1ae6..1191877 100644 --- a/index.d.ts +++ b/index.d.ts @@ -97,9 +97,9 @@ export interface AuthenticationResult { * Type of possible options for mandatory field a credential request. */ export const MandatoryEnum = { - YES = 'yes', - NO = 'no', - IF_AVAILABLE = 'if_available' + YES: 'yes', + NO: 'no', + IF_AVAILABLE: 'if_available' } as const /** From ca61d2e4dfe8c5acec2cfe50b8bb3cc8319d7064 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Thu, 10 Aug 2023 18:17:59 -0300 Subject: [PATCH 04/12] chore: add compile script --- constants.js | 11 +++++++++++ constants.ts | 8 ++++++++ index.d.ts | 11 ++--------- index.js | 4 ++++ index.ts | 1 + package-lock.json | 4 ++-- package.json | 9 ++++++--- tsconfig.json | 17 ++++++++--------- 8 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 constants.js create mode 100644 constants.ts create mode 100644 index.js create mode 100644 index.ts diff --git a/constants.js b/constants.js new file mode 100644 index 0000000..3b02efd --- /dev/null +++ b/constants.js @@ -0,0 +1,11 @@ +"use strict"; +exports.__esModule = true; +exports.MandatoryEnum = void 0; +/** + * Type of possible options for mandatory field a credential request. + */ +exports.MandatoryEnum = { + YES: 'yes', + NO: 'no', + IF_AVAILABLE: 'if_available' +}; diff --git a/constants.ts b/constants.ts new file mode 100644 index 0000000..14786b9 --- /dev/null +++ b/constants.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 1191877..903cb76 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,5 @@ +import { MandatoryEnum } from './constants'; + /**************************************** * 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 const MandatoryEnum = { - YES: 'yes', - NO: 'no', - IF_AVAILABLE: 'if_available' -} as const - /** * Represents a credential request in a presentation request */ diff --git a/index.js b/index.js new file mode 100644 index 0000000..8337bfe --- /dev/null +++ b/index.js @@ -0,0 +1,4 @@ +"use strict"; +exports.__esModule = true; +exports.constants = void 0; +exports.constants = require("./constants"); diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..e6e6cc5 --- /dev/null +++ b/index.ts @@ -0,0 +1 @@ +export * as constants from './constants' 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 a6fa043..a46ad63 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,15 @@ "name": "@unumid/core-types", "version": "0.23.2", "description": "UnumID shared core service types", - "main": "index.d.ts", + "main": "index.js", + "types": "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 index.ts" }, "repository": { "type": "git", @@ -22,5 +24,6 @@ "homepage": "https://github.com/UnumID/core-types#readme", "devDependencies": { "typescript": "^4.9.5" - } + }, + "files": ["index.d.ts", "index.js", "constants.ts", "constants.js"] } 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 From fbcf8e13195a57ee493e02c25580d256d621c188 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Thu, 10 Aug 2023 18:23:51 -0300 Subject: [PATCH 05/12] chore: update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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`. From 394c21496a5029de033677c3d74719795871cb1e Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:11:09 -0300 Subject: [PATCH 06/12] refactor: rename constants to enums --- constants.js => enums.js | 0 constants.ts => enums.ts | 0 index.js | 4 ++-- index.ts | 2 +- package.json | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename constants.js => enums.js (100%) rename constants.ts => enums.ts (100%) diff --git a/constants.js b/enums.js similarity index 100% rename from constants.js rename to enums.js diff --git a/constants.ts b/enums.ts similarity index 100% rename from constants.ts rename to enums.ts diff --git a/index.js b/index.js index 8337bfe..5a432cf 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ "use strict"; exports.__esModule = true; -exports.constants = void 0; -exports.constants = require("./constants"); +exports.enums = void 0; +exports.enums = require("./enums"); diff --git a/index.ts b/index.ts index e6e6cc5..f171790 100644 --- a/index.ts +++ b/index.ts @@ -1 +1 @@ -export * as constants from './constants' +export * as enums from './enums' diff --git a/package.json b/package.json index a46ad63..6a3f518 100644 --- a/package.json +++ b/package.json @@ -25,5 +25,5 @@ "devDependencies": { "typescript": "^4.9.5" }, - "files": ["index.d.ts", "index.js", "constants.ts", "constants.js"] + "files": ["index.d.ts", "index.js", "enums.ts", "enums.js"] } From ebd919674cb2e9e05425fcbf1768bd5820fc4e4c Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:16:25 -0300 Subject: [PATCH 07/12] chore: remove build files --- enums.js | 11 ----------- index.js | 4 ---- 2 files changed, 15 deletions(-) delete mode 100644 enums.js delete mode 100644 index.js diff --git a/enums.js b/enums.js deleted file mode 100644 index 3b02efd..0000000 --- a/enums.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -exports.__esModule = true; -exports.MandatoryEnum = void 0; -/** - * Type of possible options for mandatory field a credential request. - */ -exports.MandatoryEnum = { - YES: 'yes', - NO: 'no', - IF_AVAILABLE: 'if_available' -}; diff --git a/index.js b/index.js deleted file mode 100644 index 5a432cf..0000000 --- a/index.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -exports.__esModule = true; -exports.enums = void 0; -exports.enums = require("./enums"); From 85ab34de79e575ed2dd775fa856e6a0c0d6f5081 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:28:42 -0300 Subject: [PATCH 08/12] refactor: rename enum imports --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 903cb76..d4bb66c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import { MandatoryEnum } from './constants'; +import { MandatoryEnum } from './enums'; /**************************************** * DATA RESOLVER TYPES * From 8e75bf6c51ecf05ac928b9638d868134a9379726 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:28:48 -0300 Subject: [PATCH 09/12] chore: ignore js build --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 7aa77ae..a3f4947 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ node_modules/ .history .idea + +# Ignore build files +*.js +/*.js From bd7f7df22c84b5d76cfa1f992312d166c3b029aa Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:33:57 -0300 Subject: [PATCH 10/12] chore: ignore js build --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a3f4947..6c97830 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ node_modules/ .idea # Ignore build files -*.js -/*.js +build/ From a3d59cc4c5f4e5adf0b9bca0e0acb87ceef2ddd1 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:34:08 -0300 Subject: [PATCH 11/12] refactor: build on compile --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6a3f518..9459f5e 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,15 @@ "name": "@unumid/core-types", "version": "0.23.2", "description": "UnumID shared core service types", - "main": "index.js", - "types": "index.d.ts", + "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", - "compile": "tsc index.ts" + "compile": "tsc --build" }, "repository": { "type": "git", @@ -25,5 +25,5 @@ "devDependencies": { "typescript": "^4.9.5" }, - "files": ["index.d.ts", "index.js", "enums.ts", "enums.js"] + "files": ["build/"] } From 288ccec30878fd46c2640aec25455197d0451609 Mon Sep 17 00:00:00 2001 From: Iagor Moraes Date: Fri, 11 Aug 2023 10:35:14 -0300 Subject: [PATCH 12/12] feat: compile on ci --- .github/workflows/publish.yaml | 3 +++ 1 file changed, 3 insertions(+) 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: |