@jpmorganchase/mosaic-source-local-folder 0.1.0-beta.6 → 0.1.0-beta.60
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 +4 -4
- package/dist/fromFsWatch.js +6 -8
- package/dist/fromFsWatch.js.map +1 -1
- package/dist/index.d.ts +23 -4
- package/dist/index.js +45 -28
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
- package/CHANGELOG.md +0 -58
package/dist/fromFsWatch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import {
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { WatchOptions } from 'fs';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
-
export default function fromFsWatch(filename:
|
|
5
|
+
export default function fromFsWatch(filename: string, options?: WatchOptions | BufferEncoding | string | null | (WatchOptions & {
|
|
6
6
|
encoding: 'buffer';
|
|
7
7
|
}) | 'buffer'): Observable<unknown>;
|
package/dist/fromFsWatch.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const watcher = (0, fs_1.watch)(filename, options, (_eventType, filename) => {
|
|
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);
|
|
6
|
+
watcher.on('all', (_eventType, filename) => {
|
|
8
7
|
subscriber.next(filename);
|
|
9
8
|
});
|
|
10
9
|
watcher.once('error', (error) => {
|
|
@@ -18,5 +17,4 @@ function fromFsWatch(filename, options) {
|
|
|
18
17
|
};
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
|
-
exports.default = fromFsWatch;
|
|
22
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
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { Source } from '@jpmorganchase/mosaic-types';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export declare const schema: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* Collection of file extensions to look for
|
|
6
|
+
*/
|
|
7
|
+
extensions: z.ZodArray<z.ZodString, "atleastone">;
|
|
8
|
+
/**
|
|
9
|
+
* Add to use a folder prefix
|
|
10
|
+
*/
|
|
11
|
+
prefixDir: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* The root directory containing docs
|
|
14
|
+
*/
|
|
15
|
+
rootDir: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
extensions: [string, ...string[]];
|
|
5
18
|
rootDir: string;
|
|
6
|
-
|
|
19
|
+
prefixDir?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
extensions: [string, ...string[]];
|
|
22
|
+
rootDir: string;
|
|
23
|
+
prefixDir?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export declare type LocalFolderSourceOptions = z.infer<typeof schema>;
|
|
7
26
|
declare const LocalFolderSource: Source<LocalFolderSourceOptions>;
|
|
8
27
|
export default LocalFolderSource;
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
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';
|
|
9
|
+
async function getLastModifiedDate(fullPath) {
|
|
10
|
+
const resolvedRoute = await fs.promises.realpath(fullPath);
|
|
11
|
+
const stats = await fs.promises.stat(resolvedRoute);
|
|
12
|
+
return stats?.mtimeMs ? stats.mtimeMs : 0;
|
|
13
|
+
}
|
|
14
|
+
function createFileGlob(url, pageExtensions) {
|
|
15
|
+
if (pageExtensions.length === 1) {
|
|
16
|
+
return `${url}${pageExtensions[0]}`;
|
|
17
|
+
}
|
|
18
|
+
return `${url}{${pageExtensions.join(',')}}`;
|
|
19
|
+
}
|
|
20
|
+
export const schema = z.object({
|
|
21
|
+
/**
|
|
22
|
+
* Collection of file extensions to look for
|
|
23
|
+
*/
|
|
24
|
+
extensions: z
|
|
25
|
+
.string({ required_error: 'Please provide the collection of file extensions to look for' })
|
|
26
|
+
.array()
|
|
27
|
+
.nonempty(),
|
|
28
|
+
/**
|
|
29
|
+
* Add to use a folder prefix
|
|
30
|
+
*/
|
|
31
|
+
prefixDir: z.string().optional(),
|
|
32
|
+
/**
|
|
33
|
+
* The root directory containing docs
|
|
34
|
+
*/
|
|
35
|
+
rootDir: z.string({ required_error: 'Please provide a root directory name' })
|
|
36
|
+
});
|
|
12
37
|
const LocalFolderSource = {
|
|
13
38
|
create(options, { serialiser }) {
|
|
14
|
-
|
|
39
|
+
validateMosaicSchema(schema, options);
|
|
40
|
+
return merge(of(null), fromFsWatch(options.rootDir, { recursive: true })).pipe(delay(1000), switchMap(() => glob(createFileGlob('**', options.extensions), {
|
|
15
41
|
cwd: options.rootDir,
|
|
16
42
|
onlyFiles: true
|
|
17
|
-
})),
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
})), concatMap(async (filepaths) =>
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/return-await
|
|
45
|
+
await Promise.all(filepaths.map(async (filepath) => {
|
|
46
|
+
const fullPath = path.posix.join(options.rootDir, filepath);
|
|
47
|
+
return lodashMerge({}, await serialiser.deserialise(fullPath, await fs.promises.readFile(fullPath)), {
|
|
20
48
|
lastModified: new Date(await getLastModifiedDate(fullPath)).getTime(),
|
|
21
|
-
fullPath: `/${options.prefixDir ?
|
|
49
|
+
fullPath: `/${options.prefixDir ? path.posix.join(options.prefixDir, filepath) : filepath}`.replace(/^\/{2,}/, '/')
|
|
22
50
|
});
|
|
23
51
|
}))));
|
|
24
52
|
}
|
|
25
53
|
};
|
|
26
|
-
|
|
27
|
-
const resolvedRoute = await fs_1.default.promises.realpath(fullPath);
|
|
28
|
-
const stats = await fs_1.default.promises.stat(resolvedRoute);
|
|
29
|
-
return (stats === null || stats === void 0 ? void 0 : stats.mtimeMs) ? stats.mtimeMs : 0;
|
|
30
|
-
}
|
|
31
|
-
function createFileGlob(url, pageExtensions) {
|
|
32
|
-
if (pageExtensions.length === 1) {
|
|
33
|
-
return `${url}${pageExtensions[0]}`;
|
|
34
|
-
}
|
|
35
|
-
return `${url}{${pageExtensions.join(',')}}`;
|
|
36
|
-
}
|
|
37
|
-
exports.default = LocalFolderSource;
|
|
54
|
+
export default LocalFolderSource;
|
|
38
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,Q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,CAAC,GAAG,EAAE,CACb,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE;YAC7C,GAAG,EAAE,OAAO,CAAC,OAAO;YACpB,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,EACD,SAAS,CACP,KAAK,EAAE,SAAmB,EAAE,EAAE;QAC5B,2DAA2D;QAC3D,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAgB,EAAE,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,27 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-source-local-folder",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.60",
|
|
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-
|
|
25
|
-
"
|
|
35
|
+
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.60",
|
|
36
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.60",
|
|
37
|
+
"chokidar": "^3.5.3",
|
|
38
|
+
"fast-glob": "^3.2.12",
|
|
39
|
+
"lodash-es": "^4.17.21",
|
|
40
|
+
"rxjs": "^7.5.5",
|
|
41
|
+
"zod": "^3.22.3"
|
|
26
42
|
}
|
|
27
43
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# @jpmorganchase/mosaic-source-local-folder
|
|
2
|
-
|
|
3
|
-
## 0.1.0-beta.6
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- c103b24: Release fixes for snapshot serve
|
|
8
|
-
- Updated dependencies [c103b24]
|
|
9
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.6
|
|
10
|
-
|
|
11
|
-
## 0.1.0-beta.5
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- 61a246c: This releases add support for generate / build and serve snapshots
|
|
16
|
-
- Updated dependencies [61a246c]
|
|
17
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.5
|
|
18
|
-
|
|
19
|
-
## 0.1.0-beta.4
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- bd285df: added dist to package.json
|
|
24
|
-
- Updated dependencies [bd285df]
|
|
25
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.4
|
|
26
|
-
|
|
27
|
-
## 0.1.0-beta.3
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- 457df5e: switch to public package
|
|
32
|
-
- Updated dependencies [457df5e]
|
|
33
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.3
|
|
34
|
-
|
|
35
|
-
## 0.1.0-beta.2
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
40
|
-
|
|
41
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
42
|
-
|
|
43
|
-
- 4b2bc51: pipped to 0.1.0-beta.1 for publishing to NPM
|
|
44
|
-
- Updated dependencies [e1bbbe7]
|
|
45
|
-
- Updated dependencies [4b2bc51]
|
|
46
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.2
|
|
47
|
-
|
|
48
|
-
## 0.1.0
|
|
49
|
-
|
|
50
|
-
### Patch Changes
|
|
51
|
-
|
|
52
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
53
|
-
|
|
54
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
55
|
-
|
|
56
|
-
- Updated dependencies [e1bbbe7]
|
|
57
|
-
- Updated dependencies [bbc853c]
|
|
58
|
-
- @jpmorganchase/mosaic-types@0.1.0
|