@kwiz/common 1.0.245 → 1.0.247
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint.utils.types.js","sourceRoot":"","sources":["../../../src/types/sharepoint.utils.types.ts"],"names":[],"mappings":";;;AA0CA,qCAAqC;AACrC,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,uEAAW,CAAA;IACX,qEAAU,CAAA;IACV,uEAAW,CAAA;AACf,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AA+BD,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,iEAAU,CAAA;IACV,cAAc;IACd,iEAAU,CAAA;IACV,wDAAwD;IACxD,qEAAY,CAAA;AAChB,CAAC,EANW,mBAAmB,mCAAnB,mBAAmB,QAM9B;AAsED,qCAAqC;AACrC,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,qCAAO,CAAA;IACP,yCAAS,CAAA;AACb,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;
|
|
1
|
+
{"version":3,"file":"sharepoint.utils.types.js","sourceRoot":"","sources":["../../../src/types/sharepoint.utils.types.ts"],"names":[],"mappings":";;;AA0CA,qCAAqC;AACrC,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,uEAAW,CAAA;IACX,qEAAU,CAAA;IACV,uEAAW,CAAA;AACf,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AA+BD,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,iEAAU,CAAA;IACV,cAAc;IACd,iEAAU,CAAA;IACV,wDAAwD;IACxD,qEAAY,CAAA;AAChB,CAAC,EANW,mBAAmB,mCAAnB,mBAAmB,QAM9B;AAsED,qCAAqC;AACrC,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,qCAAO,CAAA;IACP,yCAAS,CAAA;AACb,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAkDD,qCAAqC;AACrC,IAAY,2BAA0F;AAAtG,WAAY,2BAA2B;IAAG,uGAAiB,CAAA;IAAE,2GAAmB,CAAA;IAAE,yGAAkB,CAAA;AAAC,CAAC,EAA1F,2BAA2B,2CAA3B,2BAA2B,QAA+D;AAuEtG;;EAEE;AACF,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IACxB,iCAAiC;IACjC,+DAAQ,CAAA;IACR,8CAA8C;IAC9C,+DAAQ,CAAA;IACR,yCAAyC;IACzC,6DAAO,CAAA;IACP,0DAA0D;IAC1D,yDAAK,CAAA;IACL,0EAA0E;IAC1E,iEAAS,CAAA;AACb,CAAC,EAXW,gBAAgB,gCAAhB,gBAAgB,QAW3B;AAED;;EAEE;AACF,IAAY,SAOX;AAPD,WAAY,SAAS;IACjB,iFAAiF;IACjF,mDAAa,CAAA;IACb,sEAAsE;IACtE,2CAAS,CAAA;IACT,6FAA6F;IAC7F,mDAAc,CAAA;AAClB,CAAC,EAPW,SAAS,yBAAT,SAAS,QAOpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharepoint.utils.types.js","sourceRoot":"","sources":["../../../src/types/sharepoint.utils.types.ts"],"names":[],"mappings":"AA0CA,qCAAqC;AACrC,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,uEAAW,CAAA;IACX,qEAAU,CAAA;IACV,uEAAW,CAAA;AACf,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC;AA+BD,MAAM,CAAN,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,iEAAU,CAAA;IACV,cAAc;IACd,iEAAU,CAAA;IACV,wDAAwD;IACxD,qEAAY,CAAA;AAChB,CAAC,EANW,mBAAmB,KAAnB,mBAAmB,QAM9B;AAsED,qCAAqC;AACrC,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,qCAAO,CAAA;IACP,yCAAS,CAAA;AACb,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;
|
|
1
|
+
{"version":3,"file":"sharepoint.utils.types.js","sourceRoot":"","sources":["../../../src/types/sharepoint.utils.types.ts"],"names":[],"mappings":"AA0CA,qCAAqC;AACrC,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,uEAAW,CAAA;IACX,qEAAU,CAAA;IACV,uEAAW,CAAA;AACf,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC;AA+BD,MAAM,CAAN,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,iEAAU,CAAA;IACV,cAAc;IACd,iEAAU,CAAA;IACV,wDAAwD;IACxD,qEAAY,CAAA;AAChB,CAAC,EANW,mBAAmB,KAAnB,mBAAmB,QAM9B;AAsED,qCAAqC;AACrC,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,qCAAO,CAAA;IACP,yCAAS,CAAA;AACb,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAkDD,qCAAqC;AACrC,MAAM,CAAN,IAAY,2BAA0F;AAAtG,WAAY,2BAA2B;IAAG,uGAAiB,CAAA;IAAE,2GAAmB,CAAA;IAAE,yGAAkB,CAAA;AAAC,CAAC,EAA1F,2BAA2B,KAA3B,2BAA2B,QAA+D;AAuEtG;;EAEE;AACF,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IACxB,iCAAiC;IACjC,+DAAQ,CAAA;IACR,8CAA8C;IAC9C,+DAAQ,CAAA;IACR,yCAAyC;IACzC,6DAAO,CAAA;IACP,0DAA0D;IAC1D,yDAAK,CAAA;IACL,0EAA0E;IAC1E,iEAAS,CAAA;AACb,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B;AAED;;EAEE;AACF,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACjB,iFAAiF;IACjF,mDAAa,CAAA;IACb,sEAAsE;IACtE,2CAAS,CAAA;IACT,6FAA6F;IAC7F,mDAAc,CAAA;AAClB,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB"}
|
|
@@ -18,10 +18,23 @@ export interface ITypesDisplayInfo<ValueType> {
|
|
|
18
18
|
fabricIconName?: string;
|
|
19
19
|
}
|
|
20
20
|
export type DateOrNull = Date | null;
|
|
21
|
+
/** @deprecated prefer using iFileData2 to avoid exessive memory usage converting large files from base64 to array buffer */
|
|
21
22
|
export interface iFileData {
|
|
22
23
|
filename: string;
|
|
23
24
|
base64: string;
|
|
24
25
|
}
|
|
26
|
+
interface iFileData64 {
|
|
27
|
+
filename: string;
|
|
28
|
+
base64: string;
|
|
29
|
+
buffer?: never;
|
|
30
|
+
}
|
|
31
|
+
interface iFileDataBuffer {
|
|
32
|
+
filename: string;
|
|
33
|
+
buffer: ArrayBuffer;
|
|
34
|
+
base64?: never;
|
|
35
|
+
}
|
|
36
|
+
/** use if you support either base64 or ArrayBuffer */
|
|
37
|
+
export type tFileDataV2 = iFileData64 | iFileDataBuffer;
|
|
25
38
|
/** allow using Omit on complex join types */
|
|
26
39
|
export type DeepOmit<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
|
|
27
40
|
/** return a success flag with either error message or the value */
|
|
@@ -35,3 +48,4 @@ export type apiResultType<T> = {
|
|
|
35
48
|
export type DeepPartial<T> = {
|
|
36
49
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
37
50
|
};
|
|
51
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kwiz/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.247",
|
|
4
4
|
"description": "KWIZ common utilities and helpers for M365 platform",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"watch": "npm-run-all --parallel watch:esm watch:cjs",
|
|
18
|
-
"watch-push": "yalc push --sig",
|
|
17
|
+
"watch": "npm-run-all --parallel watch:esm watch:cjs watch:push-once",
|
|
19
18
|
"build": "npm run reindex-project && npm run build:esm && npm run build:cjs",
|
|
20
19
|
"unit-test": "node --import tsx --test src",
|
|
21
20
|
"npm-v-patch": "npm version patch && git push origin main:main && git push --tags",
|
|
@@ -32,6 +31,8 @@
|
|
|
32
31
|
"remove-all-index-files": "cd src && del /s /f /q exports-index.ts",
|
|
33
32
|
"watch:esm": "tsc-watch --project tsconfig.esm.json",
|
|
34
33
|
"watch:cjs": "tsc-watch --project tsconfig.cjs.json",
|
|
34
|
+
"watch-push": "yalc push --sig",
|
|
35
|
+
"watch:push-once": "node scripts/watch-push-once.js",
|
|
35
36
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
36
37
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
37
38
|
"build:test": "tsc -p tsconfig.test.json"
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
const { spawn } = require("node:child_process");
|
|
4
|
+
|
|
5
|
+
const rootDir = process.cwd();
|
|
6
|
+
const libDir = path.join(rootDir, "lib");
|
|
7
|
+
const targetPrefixes = ["esm", "cjs"];
|
|
8
|
+
const debounceMs = 1000;
|
|
9
|
+
|
|
10
|
+
let pushRunning = false;
|
|
11
|
+
let pendingPush = false;
|
|
12
|
+
let lastEventAt = 0;
|
|
13
|
+
let debounceTimer = null;
|
|
14
|
+
|
|
15
|
+
function shouldTrigger(filePath) {
|
|
16
|
+
if (!filePath) return false;
|
|
17
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
18
|
+
if (!targetPrefixes.some((prefix) => normalized.startsWith(prefix + "/"))) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return normalized.endsWith(".js") || normalized.endsWith(".d.ts") || normalized.endsWith(".map");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function scheduleDebouncedPush(delay = debounceMs) {
|
|
26
|
+
if (debounceTimer) {
|
|
27
|
+
clearTimeout(debounceTimer);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
debounceTimer = setTimeout(() => {
|
|
31
|
+
debounceTimer = null;
|
|
32
|
+
maybeRunPush();
|
|
33
|
+
}, delay);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onBuildEvent(filePath) {
|
|
37
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
38
|
+
const matched = targetPrefixes.find((prefix) => normalized.startsWith(prefix + "/"));
|
|
39
|
+
if (!matched) return;
|
|
40
|
+
|
|
41
|
+
pendingPush = true;
|
|
42
|
+
lastEventAt = Date.now();
|
|
43
|
+
scheduleDebouncedPush(debounceMs);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function maybeRunPush() {
|
|
47
|
+
if (!pendingPush) return;
|
|
48
|
+
|
|
49
|
+
const quietFor = Date.now() - lastEventAt;
|
|
50
|
+
if (quietFor < debounceMs) {
|
|
51
|
+
scheduleDebouncedPush(debounceMs - quietFor);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (pushRunning) {
|
|
56
|
+
scheduleDebouncedPush(debounceMs);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
runPush();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function runPush() {
|
|
64
|
+
pushRunning = true;
|
|
65
|
+
pendingPush = false;
|
|
66
|
+
|
|
67
|
+
console.log("[watch:push-once] Build output settled. Running watch-push...");
|
|
68
|
+
|
|
69
|
+
const child = spawn("npm", ["run", "watch-push"], {
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
shell: process.platform === "win32",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
child.on("error", (err) => {
|
|
75
|
+
pushRunning = false;
|
|
76
|
+
console.error(`[watch:push-once] Failed to spawn watch-push: ${err.message}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
child.on("exit", (code) => {
|
|
81
|
+
pushRunning = false;
|
|
82
|
+
|
|
83
|
+
if (code === 0) {
|
|
84
|
+
console.log("[watch:push-once] watch-push finished.");
|
|
85
|
+
if (pendingPush) {
|
|
86
|
+
scheduleDebouncedPush(debounceMs);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.error(`[watch:push-once] watch-push failed with exit code ${code}.`);
|
|
92
|
+
process.exit(code || 1);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!fs.existsSync(libDir)) {
|
|
97
|
+
console.log("[watch:push-once] Waiting for lib folder to be created...");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const watchTarget = fs.existsSync(libDir) ? libDir : rootDir;
|
|
101
|
+
|
|
102
|
+
const watcher = fs.watch(
|
|
103
|
+
watchTarget,
|
|
104
|
+
{ recursive: true },
|
|
105
|
+
(_eventType, fileName) => {
|
|
106
|
+
if (watchTarget === rootDir) {
|
|
107
|
+
if (!fileName || !fileName.replace(/\\/g, "/").startsWith("lib/")) return;
|
|
108
|
+
const rel = fileName.replace(/\\/g, "/").slice(4);
|
|
109
|
+
if (shouldTrigger(rel)) onBuildEvent(rel);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (shouldTrigger(fileName)) onBuildEvent(fileName);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
watcher.on("error", (err) => {
|
|
118
|
+
console.error("[watch:push-once] Watcher error:", err.message);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log("[watch:push-once] Listening for build output in lib/esm and lib/cjs (1s debounce)...");
|