@kwiz/node 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export * from './common';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../../src/spo/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -0,0 +1,2 @@
1
+ export * from './discovery';
2
+ export * from './msal';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./discovery"), exports);
18
+ __exportStar(require("./msal"), exports);
19
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../../src/auth/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB"}
@@ -0,0 +1,4 @@
1
+ export * from './auth/exports-index';
2
+ export * from './graph/exports-index';
3
+ export * from './spo/exports-index';
4
+ export * from './axios';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./auth/exports-index"), exports);
18
+ __exportStar(require("./graph/exports-index"), exports);
19
+ __exportStar(require("./spo/exports-index"), exports);
20
+ __exportStar(require("./axios"), exports);
21
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../src/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,wDAAsC;AACtC,sDAAoC;AACpC,0CAAwB"}
@@ -0,0 +1 @@
1
+ export * from './graph';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./graph"), exports);
18
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../../src/graph/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,5 @@
1
+ import { AuthContextType, ITenantInfo } from "@kwiz/common";
2
+ /** "https://graph.microsoft.com" */
3
+ export declare const graphScope = "https://graph.microsoft.com";
4
+ export declare function ConfigureGraphAuth(config?: AuthContextType): void;
5
+ export declare function getAxiosConfigGraph(tenantInfo: ITenantInfo): Promise<import("axios").AxiosRequestConfig<any>>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getAxiosConfigGraph = exports.ConfigureGraphAuth = exports.graphScope = void 0;
13
+ const common_1 = require("@kwiz/common");
14
+ const msal_1 = require("../auth/msal");
15
+ const axios_1 = require("../axios");
16
+ /** "https://graph.microsoft.com" */
17
+ exports.graphScope = "https://graph.microsoft.com";
18
+ var auth = null;
19
+ function ConfigureGraphAuth(config) {
20
+ auth = config;
21
+ }
22
+ exports.ConfigureGraphAuth = ConfigureGraphAuth;
23
+ function getAxiosConfigGraph(tenantInfo) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if ((0, common_1.isNullOrUndefined)(auth))
26
+ throw Error("Call ConfigureGraphAuth first");
27
+ // secret or certificate supported
28
+ let token = yield (0, msal_1.GetMSALToken)(tenantInfo, exports.graphScope, auth);
29
+ return (0, axios_1.getAxiosConfigBearer)(token);
30
+ });
31
+ }
32
+ exports.getAxiosConfigGraph = getAxiosConfigGraph;
33
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph/graph.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA+E;AAC/E,uCAA4C;AAC5C,oCAAgD;AAEhD,oCAAoC;AACvB,QAAA,UAAU,GAAG,6BAA6B,CAAC;AAExD,IAAI,IAAI,GAAoB,IAAI,CAAC;AACjC,SAAgB,kBAAkB,CAAC,MAAwB;IACvD,IAAI,GAAG,MAAM,CAAC;AAClB,CAAC;AAFD,gDAEC;AACD,SAAsB,mBAAmB,CAAC,UAAuB;;QAC7D,IAAI,IAAA,0BAAiB,EAAC,IAAI,CAAC;YAAE,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAE1E,kCAAkC;QAClC,IAAI,KAAK,GAAG,MAAM,IAAA,mBAAY,EAAC,UAAU,EAAE,kBAAU,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,IAAA,4BAAoB,EAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CAAA;AAND,kDAMC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export * from "./auth/discovery";
2
- export * from "./auth/msal";
3
- export * from "./axios";
4
- export * from "./spo/common";
1
+ export * from "./exports-index";
package/dist/index.js CHANGED
@@ -14,8 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./auth/discovery"), exports);
18
- __exportStar(require("./auth/msal"), exports);
19
- __exportStar(require("./axios"), exports);
20
- __exportStar(require("./spo/common"), exports);
17
+ __exportStar(require("./exports-index"), exports);
21
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,8CAA4B;AAC5B,0CAAwB;AACxB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
@@ -0,0 +1,27 @@
1
+ const glob = require('glob');
2
+ const fs = require("fs-extra");
3
+ const exportsFileName = "exports-index";
4
+ const exportsFileNameWithExt = `${exportsFileName}.ts`;
5
+ const exportsIndexFiles = glob.sync(`./src/**/${exportsFileNameWithExt}`);
6
+ //loop every exportsIndexFiles and find any import to a directory, and replace with /exports-index
7
+ console.time("fixing direcry imports");
8
+ exportsIndexFiles.forEach(file => {
9
+ var content = fs.readFileSync(file, "utf8").split("\n");
10
+ var parentFolderContent = fs.readdirSync(file.replace(exportsFileNameWithExt, ''));
11
+ var hasChanges = false;
12
+ //loop every import - if it does not match a file in the folder, but matches a sub-folder - append exports-index to it
13
+ content.forEach((line, idx) => {
14
+ if (line.replace(/ /g, '').length > 0) {
15
+ let importName = line.slice(line.indexOf('./') + 2, line.length - 2);
16
+ if (parentFolderContent.includes(importName))//its a folder, otherwise it would be .ts
17
+ {
18
+ content[idx] = line.replace(`./${importName}`, `./${importName}/${exportsFileName}`);
19
+ hasChanges = true;
20
+ }
21
+ }
22
+ });
23
+ if (hasChanges) {
24
+ fs.writeFileSync(file, content.join('\n'));
25
+ }
26
+ });
27
+ console.timeEnd("fixing direcry imports");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwiz/node",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "KWIZ utilities and helpers for node applications",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "scripts": {
16
16
  "watch": "tsc -watch",
17
- "build": "npm run test && tsc",
17
+ "build": "npm run reindex-project && npm run test && tsc",
18
18
  "build-explain": "tsc --explainFiles",
19
19
  "check-dependencies": "madge --circular ./src",
20
20
  "create-link": "npm link",
@@ -23,7 +23,8 @@
23
23
  "npm-v-major": "npm version major",
24
24
  "npm-publish": "npm publish --access public",
25
25
  "reset-repo": "git fetch origin && git reset --hard origin/main",
26
- "link-local-common": "npm link @kwiz/common"
26
+ "link-local-common": "npm link @kwiz/common",
27
+ "reindex-project": "cti create ./src -i _dependencies -w -b -n -o exports-index.ts && node fix-folder-imports.js"
27
28
  },
28
29
  "repository": {
29
30
  "type": "git",
@@ -56,6 +57,8 @@
56
57
  "packageManager": "npm@9.5.1",
57
58
  "devDependencies": {
58
59
  "@types/node": "^18.19.21",
60
+ "create-ts-index": "^1.14.0",
61
+ "fs-extra": "^11.2.0",
59
62
  "madge": "^6.1.0",
60
63
  "tsx": "^4.7.1",
61
64
  "typescript": "^5.3.3"
@@ -0,0 +1,2 @@
1
+ export * from './discovery';
2
+ export * from './msal';
@@ -0,0 +1,4 @@
1
+ export * from './auth/exports-index';
2
+ export * from './graph/exports-index';
3
+ export * from './spo/exports-index';
4
+ export * from './axios';
@@ -0,0 +1 @@
1
+ export * from './graph';
@@ -0,0 +1,18 @@
1
+ import { AuthContextType, ITenantInfo, isNullOrUndefined } from "@kwiz/common";
2
+ import { GetMSALToken } from "../auth/msal";
3
+ import { getAxiosConfigBearer } from "../axios";
4
+
5
+ /** "https://graph.microsoft.com" */
6
+ export const graphScope = "https://graph.microsoft.com";
7
+
8
+ var auth: AuthContextType = null;
9
+ export function ConfigureGraphAuth(config?: AuthContextType) {
10
+ auth = config;
11
+ }
12
+ export async function getAxiosConfigGraph(tenantInfo: ITenantInfo) {
13
+ if (isNullOrUndefined(auth)) throw Error("Call ConfigureGraphAuth first");
14
+
15
+ // secret or certificate supported
16
+ let token = await GetMSALToken(tenantInfo, graphScope, auth);
17
+ return getAxiosConfigBearer(token);
18
+ }
package/src/index.ts CHANGED
@@ -1,4 +1 @@
1
- export * from "./auth/discovery";
2
- export * from "./auth/msal";
3
- export * from "./axios";
4
- export * from "./spo/common";
1
+ export * from "./exports-index";
@@ -0,0 +1 @@
1
+ export * from './common';