@jpmorganchase/mosaic-source-local-folder 0.1.0-beta.8 → 0.1.0-beta.80
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.
- package/dist/fromFsWatch.d.ts +2 -2
- package/dist/fromFsWatch.js +5 -8
- package/dist/fromFsWatch.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +22 -28
- package/dist/index.js.map +1 -1
- package/package.json +19 -8
- package/CHANGELOG.md +0 -89
package/dist/fromFsWatch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { WatchOptions } from 'fs';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
export default function fromFsWatch(filename: string, options?: WatchOptions | BufferEncoding | string | null | (WatchOptions & {
|
package/dist/fromFsWatch.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return new rxjs_1.Observable(subscriber => {
|
|
7
|
-
const watcher = (0, chokidar_1.watch)(filename, options);
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { watch } from 'chokidar';
|
|
3
|
+
export default function fromFsWatch(filename, options) {
|
|
4
|
+
return new Observable(subscriber => {
|
|
5
|
+
const watcher = watch(filename, options);
|
|
8
6
|
watcher.on('all', (_eventType, filename) => {
|
|
9
7
|
subscriber.next(filename);
|
|
10
8
|
});
|
|
@@ -19,5 +17,4 @@ function fromFsWatch(filename, options) {
|
|
|
19
17
|
};
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
|
-
exports.default = fromFsWatch;
|
|
23
20
|
//# sourceMappingURL=fromFsWatch.js.map
|
package/dist/fromFsWatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromFsWatch.js","sourceRoot":"","sources":["../src/fromFsWatch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fromFsWatch.js","sourceRoot":"","sources":["../src/fromFsWatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,QAAgB,EAChB,OAMY;IAEZ,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAc,CAAC,CAAC;QAEhD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;YACzC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YACrC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,OAAO,SAAS,WAAW;YACzB,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,19 +8,19 @@ export declare const schema: z.ZodObject<{
|
|
|
8
8
|
/**
|
|
9
9
|
* Add to use a folder prefix
|
|
10
10
|
*/
|
|
11
|
-
prefixDir: z.ZodString
|
|
11
|
+
prefixDir: z.ZodOptional<z.ZodString>;
|
|
12
12
|
/**
|
|
13
13
|
* The root directory containing docs
|
|
14
14
|
*/
|
|
15
15
|
rootDir: z.ZodString;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
17
|
extensions: [string, ...string[]];
|
|
18
|
-
prefixDir: string;
|
|
19
18
|
rootDir: string;
|
|
19
|
+
prefixDir?: string | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
extensions: [string, ...string[]];
|
|
22
|
-
prefixDir: string;
|
|
23
22
|
rootDir: string;
|
|
23
|
+
prefixDir?: string | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
export declare type LocalFolderSourceOptions = z.infer<typeof schema>;
|
|
26
26
|
declare const LocalFolderSource: Source<LocalFolderSourceOptions>;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
12
|
-
const zod_1 = require("zod");
|
|
13
|
-
const mosaic_schemas_1 = require("@jpmorganchase/mosaic-schemas");
|
|
14
|
-
const fromFsWatch_1 = __importDefault(require("./fromFsWatch"));
|
|
1
|
+
import { concatMap, delay, merge, of, switchMap } from 'rxjs';
|
|
2
|
+
import glob from 'fast-glob';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { merge as lodashMerge } from 'lodash-es';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { validateMosaicSchema } from '@jpmorganchase/mosaic-schemas';
|
|
8
|
+
import fromFsWatch from './fromFsWatch.js';
|
|
15
9
|
async function getLastModifiedDate(fullPath) {
|
|
16
|
-
const resolvedRoute = await
|
|
17
|
-
const stats = await
|
|
18
|
-
return
|
|
10
|
+
const resolvedRoute = await fs.promises.realpath(fullPath);
|
|
11
|
+
const stats = await fs.promises.stat(resolvedRoute);
|
|
12
|
+
return stats?.mtimeMs ? stats.mtimeMs : 0;
|
|
19
13
|
}
|
|
20
14
|
function createFileGlob(url, pageExtensions) {
|
|
21
15
|
if (pageExtensions.length === 1) {
|
|
@@ -23,39 +17,39 @@ function createFileGlob(url, pageExtensions) {
|
|
|
23
17
|
}
|
|
24
18
|
return `${url}{${pageExtensions.join(',')}}`;
|
|
25
19
|
}
|
|
26
|
-
|
|
20
|
+
export const schema = z.object({
|
|
27
21
|
/**
|
|
28
22
|
* Collection of file extensions to look for
|
|
29
23
|
*/
|
|
30
|
-
extensions:
|
|
24
|
+
extensions: z
|
|
31
25
|
.string({ required_error: 'Please provide the collection of file extensions to look for' })
|
|
32
26
|
.array()
|
|
33
27
|
.nonempty(),
|
|
34
28
|
/**
|
|
35
29
|
* Add to use a folder prefix
|
|
36
30
|
*/
|
|
37
|
-
prefixDir:
|
|
31
|
+
prefixDir: z.string().optional(),
|
|
38
32
|
/**
|
|
39
33
|
* The root directory containing docs
|
|
40
34
|
*/
|
|
41
|
-
rootDir:
|
|
35
|
+
rootDir: z.string({ required_error: 'Please provide a root directory name' })
|
|
42
36
|
});
|
|
43
37
|
const LocalFolderSource = {
|
|
44
38
|
create(options, { serialiser }) {
|
|
45
|
-
|
|
46
|
-
return
|
|
39
|
+
validateMosaicSchema(schema, options);
|
|
40
|
+
return merge(of(null), fromFsWatch(options.rootDir, { recursive: true })).pipe(delay(1000), switchMap(() => glob(createFileGlob('**', options.extensions), {
|
|
47
41
|
cwd: options.rootDir,
|
|
48
42
|
onlyFiles: true
|
|
49
|
-
})),
|
|
43
|
+
})), concatMap(async (filepaths) =>
|
|
50
44
|
// eslint-disable-next-line @typescript-eslint/return-await
|
|
51
45
|
await Promise.all(filepaths.map(async (filepath) => {
|
|
52
|
-
const fullPath =
|
|
53
|
-
return (
|
|
46
|
+
const fullPath = path.posix.join(options.rootDir, filepath);
|
|
47
|
+
return lodashMerge({}, await serialiser.deserialise(fullPath, await fs.promises.readFile(fullPath)), {
|
|
54
48
|
lastModified: new Date(await getLastModifiedDate(fullPath)).getTime(),
|
|
55
|
-
fullPath: `/${options.prefixDir ?
|
|
49
|
+
fullPath: `/${options.prefixDir ? path.posix.join(options.prefixDir, filepath) : filepath}`.replace(/^\/{2,}/, '/')
|
|
56
50
|
});
|
|
57
51
|
}))));
|
|
58
52
|
}
|
|
59
53
|
};
|
|
60
|
-
|
|
54
|
+
export default LocalFolderSource;
|
|
61
55
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAc,EAAE,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACjD,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,cAAc,CAAC,GA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,EAAE;YACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC5D,OAAO,WAAW,CAChB,EAAE,EACF,MAAM,UAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAC5E;gBACE,YAAY,EAAE,IAAI,IAAI,CAAC,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE;gBACrE,QAAQ,EAAE,IACR,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QACrE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;aAC3B,CACF,CAAC;QACJ,CAAC,CAAC,CACH,CACJ,CACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-source-local-folder",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.80",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic local folder source for core file system",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
|
+
"type": "module",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"node": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
9
18
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
19
|
+
"node": ">=16.10.0 || >=18.0.0"
|
|
11
20
|
},
|
|
12
21
|
"files": [
|
|
13
22
|
"dist"
|
|
14
23
|
],
|
|
15
24
|
"scripts": {
|
|
16
25
|
"build": "tsc",
|
|
17
|
-
"clean": "rm -fr dist"
|
|
26
|
+
"clean": "rm -fr dist",
|
|
27
|
+
"lint": "eslint --ignore-pattern \"**/__tests__/**\""
|
|
18
28
|
},
|
|
19
29
|
"repository": {
|
|
20
30
|
"type": "git",
|
|
21
|
-
"url": "git@github.com:jpmorganchase/mosaic.git"
|
|
31
|
+
"url": "git@github.com:jpmorganchase/mosaic.git",
|
|
32
|
+
"directory": "packages/source-local-folder"
|
|
22
33
|
},
|
|
23
34
|
"dependencies": {
|
|
24
|
-
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.
|
|
25
|
-
"@jpmorganchase/mosaic-types": "^0.1.0-beta.
|
|
35
|
+
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.80",
|
|
36
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.80",
|
|
26
37
|
"chokidar": "^3.5.3",
|
|
27
38
|
"fast-glob": "^3.2.12",
|
|
28
|
-
"lodash": "^4.17.21",
|
|
39
|
+
"lodash-es": "^4.17.21",
|
|
29
40
|
"rxjs": "^7.5.5",
|
|
30
|
-
"zod": "^3.
|
|
41
|
+
"zod": "^3.22.3"
|
|
31
42
|
}
|
|
32
43
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# @jpmorganchase/mosaic-source-local-folder
|
|
2
|
-
|
|
3
|
-
## 0.1.0-beta.8
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 2dca0b1: initial release of Mosaic store package
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- Updated dependencies [2dca0b1]
|
|
12
|
-
- @jpmorganchase/mosaic-schemas@0.1.0-beta.8
|
|
13
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.8
|
|
14
|
-
|
|
15
|
-
## 0.1.0-beta.7
|
|
16
|
-
|
|
17
|
-
### Minor Changes
|
|
18
|
-
|
|
19
|
-
- f82c397: Initial release of theme and client side search
|
|
20
|
-
|
|
21
|
-
We are iterating towards deploying our site code.
|
|
22
|
-
|
|
23
|
-
This release includes
|
|
24
|
-
|
|
25
|
-
- initial work for client-side search support
|
|
26
|
-
- Mosaic theme.
|
|
27
|
-
|
|
28
|
-
### Patch Changes
|
|
29
|
-
|
|
30
|
-
- Updated dependencies [f82c397]
|
|
31
|
-
- @jpmorganchase/mosaic-schemas@0.1.0-beta.7
|
|
32
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.7
|
|
33
|
-
|
|
34
|
-
## 0.1.0-beta.6
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- c103b24: Release fixes for snapshot serve
|
|
39
|
-
- Updated dependencies [c103b24]
|
|
40
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.6
|
|
41
|
-
|
|
42
|
-
## 0.1.0-beta.5
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- 61a246c: This releases add support for generate / build and serve snapshots
|
|
47
|
-
- Updated dependencies [61a246c]
|
|
48
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.5
|
|
49
|
-
|
|
50
|
-
## 0.1.0-beta.4
|
|
51
|
-
|
|
52
|
-
### Patch Changes
|
|
53
|
-
|
|
54
|
-
- bd285df: added dist to package.json
|
|
55
|
-
- Updated dependencies [bd285df]
|
|
56
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.4
|
|
57
|
-
|
|
58
|
-
## 0.1.0-beta.3
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- 457df5e: switch to public package
|
|
63
|
-
- Updated dependencies [457df5e]
|
|
64
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.3
|
|
65
|
-
|
|
66
|
-
## 0.1.0-beta.2
|
|
67
|
-
|
|
68
|
-
### Patch Changes
|
|
69
|
-
|
|
70
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
71
|
-
|
|
72
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
73
|
-
|
|
74
|
-
- 4b2bc51: pipped to 0.1.0-beta.1 for publishing to NPM
|
|
75
|
-
- Updated dependencies [e1bbbe7]
|
|
76
|
-
- Updated dependencies [4b2bc51]
|
|
77
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.2
|
|
78
|
-
|
|
79
|
-
## 0.1.0
|
|
80
|
-
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
84
|
-
|
|
85
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
86
|
-
|
|
87
|
-
- Updated dependencies [e1bbbe7]
|
|
88
|
-
- Updated dependencies [bbc853c]
|
|
89
|
-
- @jpmorganchase/mosaic-types@0.1.0
|