diff --git a/README.md b/README.md index 44273a0..cb3d948 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ In order to use this library you need to have access to an Oracle Field Service ## Installation -1. Clone the repository -2. Add the dependency to your project +1. Add the dependency to your project - `npm install ` + `npm install ` (if you have cloned the repository) -3. To use the library in your code: + `npm install https://github.com/oracle-samples/ofs-proxy-js.git` (when installing directly from GitHub) + +2. To use the library in your code: `import {OFSPlugin} from "@ofs_users/proxy"` diff --git a/package-lock.json b/package-lock.json index 6de80ab..6cced61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "jest-environment-jsdom": "^29.3.1", "prettier": "^2.8.1", "pretty-quick": "^3.1.3", + "rollup-plugin-dts": "^5.3.0", "ts-jest": "^29.0.3", "ts-loader": "^9.4.2", "ts-node": "^10.9.1", @@ -4199,6 +4200,24 @@ "yallist": "^3.0.2" } }, + "node_modules/magic-string": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.1.tgz", + "integrity": "sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/magic-string/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -4746,6 +4765,45 @@ "node": ">=10" } }, + "node_modules/rollup": { + "version": "3.26.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.26.3.tgz", + "integrity": "sha512-7Tin0C8l86TkpcMtXvQu6saWH93nhG3dGQ1/+l5V2TDMceTxO7kDiK6GzbfLWNNxqJXm591PcEZUozZm51ogwQ==", + "dev": true, + "peer": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-dts": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz", + "integrity": "sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==", + "dev": true, + "dependencies": { + "magic-string": "^0.30.0" + }, + "engines": { + "node": ">=v14" + }, + "funding": { + "url": "https://github.com/sponsors/Swatinem" + }, + "optionalDependencies": { + "@babel/code-frame": "^7.18.6" + }, + "peerDependencies": { + "rollup": "^3.0.0", + "typescript": "^4.1 || ^5.0" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -9045,6 +9103,23 @@ "yallist": "^3.0.2" } }, + "magic-string": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.1.tgz", + "integrity": "sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "dependencies": { + "@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + } + } + }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -9456,6 +9531,26 @@ "integrity": "sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==", "dev": true }, + "rollup": { + "version": "3.26.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.26.3.tgz", + "integrity": "sha512-7Tin0C8l86TkpcMtXvQu6saWH93nhG3dGQ1/+l5V2TDMceTxO7kDiK6GzbfLWNNxqJXm591PcEZUozZm51ogwQ==", + "dev": true, + "peer": true, + "requires": { + "fsevents": "~2.3.2" + } + }, + "rollup-plugin-dts": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz", + "integrity": "sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.18.6", + "magic-string": "^0.30.0" + } + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/package.json b/package.json index f844674..cbf8445 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "description": "A Javascript proxy to access Oracle Field Service via REST API", "main": "dist/ofs.es.js", "module": "dist/ofs.es.js", - "types": "dist/src/OFS.d.ts", + "types": "dist/OFS.d.ts", "repository": { "url": "https://github.com/oracle-samples/ofs-proxy-js" }, @@ -17,7 +17,8 @@ "build": "tsc", "start": "ts-node src/index.ts", "test": "jest", - "dist": "rollup --config rollup.config.mjs" + "dist": "rollup --config rollup.config.mjs", + "prepare": "npm run dist" }, "keywords": [ "ofsc", @@ -56,6 +57,7 @@ "jest-environment-jsdom": "^29.3.1", "prettier": "^2.8.1", "pretty-quick": "^3.1.3", + "rollup-plugin-dts": "^5.3.0", "ts-jest": "^29.0.3", "ts-loader": "^9.4.2", "ts-node": "^10.9.1", @@ -64,4 +66,4 @@ "dependencies": { "tslib": "^2.4.1" } -} +} \ No newline at end of file diff --git a/rollup.config.mjs b/rollup.config.mjs index 1354bcf..f793804 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -5,22 +5,33 @@ import typescript from "@rollup/plugin-typescript"; import terser from "@rollup/plugin-terser"; -export default { - input: "src/OFS.ts", - output: { - name: "OFS", - file: "dist/ofs.es.js", - format: "es", +import dts from "rollup-plugin-dts"; +const config = [ + { + input: "src/OFS.ts", + output: { + name: "OFS", + file: "dist/ofs.es.js", + format: "es", + }, + plugins: [ + typescript(), + terser({ + compress: { + unsafe: true, + }, + mangle: true, + keep_fnames: true, + keep_classnames: true, + }), + ], }, - plugins: [ - typescript(), - terser({ - compress: { - unsafe: true, - }, - mangle: true, - keep_fnames: true, - keep_classnames: true, - }), - ], -}; + { + // path to your declaration files root + input: "dist/build/types/src/OFS.d.ts", + output: [{ file: "dist/OFS.d.ts", format: "es" }], + plugins: [dts()], + }, +]; + +export default config; diff --git a/src/model.ts b/src/model.ts index f332e87..7bd14e4 100644 --- a/src/model.ts +++ b/src/model.ts @@ -63,9 +63,16 @@ export interface ActivityListResponse { } export class OFSSubscriptionResponse extends OFSResponse { - data!: SubscriptionListResponse; + data: SubscriptionListResponse = { + totalResults: 0, + items: [], + links: undefined, + }; } export class OFSActivityResponse extends OFSResponse { - data!: ActivityResponse; + data: ActivityResponse = { + customerName: undefined, + activityId: 0, + }; } diff --git a/tsconfig.json b/tsconfig.json index 2fb845c..bc279d9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,7 @@ /* Modules */ "module": "ES2022", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ + // "rootDir": ".", /* Specify the root folder within your source files. */ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ @@ -49,7 +49,7 @@ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "build", /* Specify an output folder for all emitted files. */ + "outDir": "./build", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ @@ -65,7 +65,7 @@ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + "declarationDir": "build/types", /* Specify the output directory for generated declaration files. */ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ /* Interop Constraints */