@haibun/domain-storage 1.5.0 → 1.8.2
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/build/AStorage.d.ts +23 -11
- package/build/AStorage.d.ts.map +1 -1
- package/build/AStorage.js +47 -17
- package/build/AStorage.js.map +1 -1
- package/build/AStorage.test.d.ts +1 -0
- package/build/AStorage.test.d.ts.map +1 -0
- package/build/AStorage.test.js +2 -0
- package/build/AStorage.test.js.map +1 -0
- package/build/domain-storage.d.ts +31 -4
- package/build/domain-storage.d.ts.map +1 -1
- package/build/domain-storage.js +20 -1
- package/build/domain-storage.js.map +1 -1
- package/package.json +2 -5
package/build/AStorage.d.ts
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { AStepper,
|
|
2
|
+
import { AStepper, TNamed } from "@haibun/core/build/lib/defs";
|
|
3
|
+
import { TLocationOptions, TMediaType } from "./domain-storage";
|
|
3
4
|
export declare abstract class AStorage extends AStepper {
|
|
4
5
|
abstract readFile(path: string, coding?: string): any;
|
|
5
6
|
abstract readdir(dir: string): any;
|
|
6
|
-
abstract writeFileBuffer(file: string, contents: Buffer): void;
|
|
7
|
-
writeFile(file: string, contents: string | Buffer): Promise<void>;
|
|
7
|
+
abstract writeFileBuffer(file: string, contents: Buffer, mediaType: TMediaType): void;
|
|
8
|
+
writeFile(file: string, contents: string | Buffer, mediaType: TMediaType): Promise<void>;
|
|
8
9
|
abstract stat(dir: string): any;
|
|
9
10
|
abstract mkdir(dir: string): any;
|
|
10
11
|
abstract mkdirp(dir: string): any;
|
|
11
12
|
abstract exists(ntt: string): any;
|
|
12
13
|
rmrf(dir: string): Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
fromCaptureDir(mediaType: TMediaType, ...where: string[]): string;
|
|
15
|
+
locator(loc: TLocationOptions, ...where: (string | undefined)[]): string;
|
|
16
|
+
getCaptureDir(loc: TLocationOptions, app?: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Overload this where slash directory conventions aren't used.
|
|
19
|
+
* Should not be used for any storage method that writes (that should be done in the function).
|
|
20
|
+
* @param relativeTo - flag to return a relative location
|
|
21
|
+
*/
|
|
22
|
+
pathed(mediaType: TMediaType, f: string, relativeTo?: string): string;
|
|
23
|
+
ensureCaptureDir(loc: TLocationOptions, app?: string | undefined, fn?: string): Promise<string>;
|
|
24
|
+
ensureDirExists(dir: string): Promise<void>;
|
|
20
25
|
steps: {
|
|
21
26
|
readFile: {
|
|
22
27
|
gwta: string;
|
|
23
28
|
action: ({ where }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
24
29
|
};
|
|
30
|
+
clearFiles: {
|
|
31
|
+
gwta: string;
|
|
32
|
+
action: ({ where }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
33
|
+
};
|
|
34
|
+
clearAllFiles: {
|
|
35
|
+
gwta: string;
|
|
36
|
+
action: () => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
|
|
37
|
+
};
|
|
25
38
|
};
|
|
26
39
|
}
|
|
27
|
-
export declare const BASE_STORAGE: string;
|
|
28
40
|
//# sourceMappingURL=AStorage.d.ts.map
|
package/build/AStorage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AStorage.d.ts","sourceRoot":"","sources":["../src/AStorage.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AStorage.d.ts","sourceRoot":"","sources":["../src/AStorage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAW,QAAQ,EAAM,MAAM,EAAiB,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,8BAAsB,QAAS,SAAQ,QAAQ;IAC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object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AStorage = void 0;
|
|
4
4
|
const defs_1 = require("@haibun/core/build/lib/defs");
|
|
5
5
|
class AStorage extends defs_1.AStepper {
|
|
6
6
|
constructor() {
|
|
@@ -10,35 +10,67 @@ class AStorage extends defs_1.AStepper {
|
|
|
10
10
|
gwta: `read text from {where: STORAGE_ITEM}`,
|
|
11
11
|
action: async ({ where }) => {
|
|
12
12
|
const text = await this.readFile(where, 'utf-8');
|
|
13
|
+
this.getWorld().logger.log(text);
|
|
14
|
+
return defs_1.OK;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
clearFiles: {
|
|
18
|
+
gwta: `clear files matching {where}`,
|
|
19
|
+
action: async ({ where }) => {
|
|
20
|
+
const dirs = where.split(',').map(d => d.trim());
|
|
21
|
+
for (const dir of dirs) {
|
|
22
|
+
await this.rmrf(dir);
|
|
23
|
+
}
|
|
24
|
+
return defs_1.OK;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
clearAllFiles: {
|
|
28
|
+
gwta: `clear files`,
|
|
29
|
+
action: async () => {
|
|
30
|
+
await this.rmrf('');
|
|
13
31
|
return defs_1.OK;
|
|
14
32
|
}
|
|
15
33
|
}
|
|
16
34
|
};
|
|
17
35
|
}
|
|
18
|
-
async writeFile(file, contents) {
|
|
36
|
+
async writeFile(file, contents, mediaType) {
|
|
19
37
|
if (typeof contents === 'string') {
|
|
20
|
-
await this.writeFileBuffer(file, Buffer.from(contents));
|
|
38
|
+
await this.writeFileBuffer(file, Buffer.from(contents), mediaType);
|
|
21
39
|
}
|
|
22
|
-
await this.writeFileBuffer(file, contents);
|
|
40
|
+
await this.writeFileBuffer(file, contents, mediaType);
|
|
23
41
|
}
|
|
24
42
|
async rmrf(dir) {
|
|
25
|
-
throw Error(
|
|
43
|
+
throw Error(`rmrf not implemented at ${dir}`);
|
|
26
44
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
app && p.push(app);
|
|
30
|
-
return this.pathed('.' + p.join('/'));
|
|
45
|
+
fromCaptureDir(mediaType, ...where) {
|
|
46
|
+
return [`./${defs_1.CAPTURE}`, ...where].join('/');
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
locator(loc, ...where) {
|
|
49
|
+
const { options } = loc;
|
|
50
|
+
const path = [options.base, defs_1.CAPTURE, options.DEST || defs_1.DEFAULT_DEST].concat(where.filter(w => w !== undefined));
|
|
51
|
+
return '.' + path.join('/');
|
|
35
52
|
}
|
|
36
|
-
async
|
|
37
|
-
const
|
|
38
|
-
this.
|
|
53
|
+
async getCaptureDir(loc, app) {
|
|
54
|
+
const { tag } = loc;
|
|
55
|
+
return this.locator(loc, `loop-${tag.loop}`, `seq-${tag.sequence}`, `featn-${tag.featureNum}`, `mem-${tag.member}`, app);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Overload this where slash directory conventions aren't used.
|
|
59
|
+
* Should not be used for any storage method that writes (that should be done in the function).
|
|
60
|
+
* @param relativeTo - flag to return a relative location
|
|
61
|
+
*/
|
|
62
|
+
pathed(mediaType, f, relativeTo) {
|
|
63
|
+
if (relativeTo) {
|
|
64
|
+
return f.replace(relativeTo, '.');
|
|
65
|
+
}
|
|
66
|
+
return f;
|
|
39
67
|
}
|
|
40
68
|
async ensureCaptureDir(loc, app, fn = '') {
|
|
41
69
|
const dir = await this.getCaptureDir(loc, app);
|
|
70
|
+
await this.ensureDirExists(dir);
|
|
71
|
+
return `${dir}/${fn}`;
|
|
72
|
+
}
|
|
73
|
+
async ensureDirExists(dir) {
|
|
42
74
|
if (!this.exists(dir)) {
|
|
43
75
|
try {
|
|
44
76
|
this.mkdirp(dir);
|
|
@@ -47,9 +79,7 @@ class AStorage extends defs_1.AStepper {
|
|
|
47
79
|
throw Error(`creating ${dir}: ${e}`);
|
|
48
80
|
}
|
|
49
81
|
}
|
|
50
|
-
return `${dir}/${fn}`;
|
|
51
82
|
}
|
|
52
83
|
}
|
|
53
84
|
exports.AStorage = AStorage;
|
|
54
|
-
exports.BASE_STORAGE = `${defs_1.BASE_PREFIX}STORAGE`;
|
|
55
85
|
//# sourceMappingURL=AStorage.js.map
|
package/build/AStorage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AStorage.js","sourceRoot":"","sources":["../src/AStorage.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"AStorage.js","sourceRoot":"","sources":["../src/AStorage.ts"],"names":[],"mappings":";;;AAAA,sDAA2F;AAG3F,MAAsB,QAAS,SAAQ,eAAQ;IAA/C;;QA+DI,UAAK,GAAG;YACJ,QAAQ,EAAE;gBACN,IAAI,EAAE,sCAAsC;gBAC5C,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,EAAU,EAAE,EAAE;oBAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBACjD,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACjC,OAAO,SAAE,CAAC;gBACd,CAAC;aACJ;YACD,UAAU,EAAE;gBACR,IAAI,EAAE,8BAA8B;gBACpC,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,EAAU,EAAE,EAAE;oBAChC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;oBACjD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;wBACpB,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACxB;oBACD,OAAO,SAAE,CAAC;gBACd,CAAC;aACJ;YACD,aAAa,EAAE;gBACX,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE,KAAK,IAAI,EAAE;oBACf,MAA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E,EAAE,OAAO,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,GAAG,CAAC,UAAU,EAAE,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC;IAC7H,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAqB,EAAE,CAAS,EAAE,UAAmB;QACxD,IAAI,UAAU,EAAE;YACZ,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;SACrC;QAED,OAAO,CAAC,CAAC;IACb,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,GAAqB,EAAE,GAAwB,EAAE,EAAE,GAAG,EAAE;QAC3E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC;IAC1B,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,GAAW;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACnB,IAAI;gBACA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aACpB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,CAAA;aACvC;SACJ;IACL,CAAC;CA6BJ;AA1FD,4BA0FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=AStorage.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AStorage.test.d.ts","sourceRoot":"","sources":["../src/AStorage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AStorage.test.js","sourceRoot":"","sources":["../src/AStorage.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { WorkspaceContext } from '@haibun/core/build/lib/contexts';
|
|
2
|
-
import { TNamed, TVStep, AStepper, TFromDomain, TFileTypeDomain } from '@haibun/core/build/lib/defs';
|
|
2
|
+
import { TNamed, TVStep, AStepper, TFromDomain, TFileTypeDomain, TExtraOptions, TFeatureResult, TOptions, TTag, TWorld } from '@haibun/core/build/lib/defs';
|
|
3
3
|
export declare const STORAGE_LOCATION = "STORAGE_LOCATION";
|
|
4
4
|
export declare const STORAGE_ITEM = "STORAGE_ITEM";
|
|
5
5
|
export declare const storageLocation: TFileTypeDomain;
|
|
6
|
+
export interface ICreateStorageDestination {
|
|
7
|
+
createStorageDestination(dest: string, params: any): any;
|
|
8
|
+
}
|
|
6
9
|
export declare const storageItem: TFromDomain;
|
|
7
10
|
declare const DomainStorage: {
|
|
8
11
|
new (): {
|
|
@@ -34,13 +37,37 @@ declare const DomainStorage: {
|
|
|
34
37
|
}>;
|
|
35
38
|
};
|
|
36
39
|
};
|
|
37
|
-
world?:
|
|
40
|
+
world?: TWorld | undefined;
|
|
38
41
|
close?(): void;
|
|
39
42
|
endFeature?(): void;
|
|
40
43
|
onFailure?(result: import("@haibun/core/build/lib/defs").TStepResult): void;
|
|
41
|
-
setWorld(world:
|
|
42
|
-
getWorld():
|
|
44
|
+
setWorld(world: TWorld, steppers: AStepper[]): void;
|
|
45
|
+
getWorld(): TWorld;
|
|
43
46
|
};
|
|
44
47
|
};
|
|
45
48
|
export default DomainStorage;
|
|
49
|
+
export declare const enum EMediaTypes {
|
|
50
|
+
html = "html",
|
|
51
|
+
video = "video",
|
|
52
|
+
json = "json",
|
|
53
|
+
image = "image"
|
|
54
|
+
}
|
|
55
|
+
export declare type TMediaType = EMediaTypes;
|
|
56
|
+
export declare type TLocationOptions = {
|
|
57
|
+
tag: TTag;
|
|
58
|
+
options: TOptions;
|
|
59
|
+
extraOptions: TExtraOptions;
|
|
60
|
+
mediaType: TMediaType;
|
|
61
|
+
};
|
|
62
|
+
export interface ITraceResult {
|
|
63
|
+
writeTraceFile(loc: TLocationOptions, result: TFeatureResult): any;
|
|
64
|
+
}
|
|
65
|
+
export interface IReviewResult {
|
|
66
|
+
writeReview(loc: TLocationOptions, result: TFeatureResult): any;
|
|
67
|
+
}
|
|
68
|
+
export interface IPublishResults {
|
|
69
|
+
publishResults(world: TWorld): any;
|
|
70
|
+
}
|
|
71
|
+
export declare function guessMediaExt(file: string): any;
|
|
72
|
+
export declare function guessMediaType(file: string): EMediaTypes;
|
|
46
73
|
//# sourceMappingURL=domain-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-storage.d.ts","sourceRoot":"","sources":["../src/domain-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAe,MAAM,EAAE,MAAM,EAAM,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"domain-storage.d.ts","sourceRoot":"","sources":["../src/domain-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAe,MAAM,EAAE,MAAM,EAAM,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAe,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1L,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAC;CACpD;AAED,eAAO,MAAM,WAAW,EAAE,WAA0E,CAAC;AAErG,QAAA,MAAM,aAAa;;;4BAKI,MAAM;;;;+BAIR,MAAM;;;;;;;;;;;;oCAMK,MAAM,SAAS,MAAM;;;;mCAOtB,MAAM;kCAGP,MAAM,KAAK,MAAM,aAAa,gBAAgB;;;;;;;;;;;;;CAM3E,CAAC;AAEF,eAAe,aAAa,CAAC;AAa7B,0BAAkB,WAAW;IAC3B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,UAAU,GAAG,WAAW,CAAC;AAErC,oBAAY,gBAAgB,GAAG;IAC7B,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,QAAQ,CAAC;IAClB,YAAY,EAAE,aAAa,CAAC;IAC5B,SAAS,EAAE,UAAU,CAAA;CACtB,CAAA;AAED,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,GAAG,CAAC;CACpE;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,GAAG,CAAC;CACjE;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;CACpC;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,OAGzC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,eAI1C"}
|
package/build/domain-storage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storageItem = exports.storageLocation = exports.STORAGE_ITEM = exports.STORAGE_LOCATION = void 0;
|
|
3
|
+
exports.guessMediaType = exports.guessMediaExt = exports.storageItem = exports.storageLocation = exports.STORAGE_ITEM = exports.STORAGE_LOCATION = void 0;
|
|
4
4
|
const defs_1 = require("@haibun/core/build/lib/defs");
|
|
5
5
|
const util_1 = require("@haibun/core/build/lib/util");
|
|
6
6
|
exports.STORAGE_LOCATION = 'STORAGE_LOCATION';
|
|
@@ -47,4 +47,23 @@ const DomainStorage = class DomainStorage extends defs_1.AStepper {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
exports.default = DomainStorage;
|
|
50
|
+
const MAPPED_MEDIA_TYPES = {
|
|
51
|
+
webm: 'video'
|
|
52
|
+
};
|
|
53
|
+
const MEDIA_TYPES = {
|
|
54
|
+
html: 'text/html',
|
|
55
|
+
json: 'json',
|
|
56
|
+
'video': 'video/mp4'
|
|
57
|
+
};
|
|
58
|
+
function guessMediaExt(file) {
|
|
59
|
+
const ext = file.replace(/.*\./, '').toLowerCase();
|
|
60
|
+
return MAPPED_MEDIA_TYPES[ext] || ext;
|
|
61
|
+
}
|
|
62
|
+
exports.guessMediaExt = guessMediaExt;
|
|
63
|
+
function guessMediaType(file) {
|
|
64
|
+
const ext = guessMediaExt(file);
|
|
65
|
+
const mediaType = MEDIA_TYPES[ext] || ext.toUpperCase().replace(/[^A-Z]/g, '');
|
|
66
|
+
return mediaType;
|
|
67
|
+
}
|
|
68
|
+
exports.guessMediaType = guessMediaType;
|
|
50
69
|
//# sourceMappingURL=domain-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-storage.js","sourceRoot":"","sources":["../src/domain-storage.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"domain-storage.js","sourceRoot":"","sources":["../src/domain-storage.ts"],"names":[],"mappings":";;;AACA,sDAA0L;AAC1L,sDAA4D;AAE/C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,YAAY,GAAG,cAAc,CAAC;AAE9B,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,wBAAgB,EAAE,QAAQ,EAAE,wBAAgB,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,OAAe,EAAE,EAAE;QAC9F,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC;AAMW,QAAA,WAA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WAAW;IACjB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,WAAW;CACrB,CAAA;AA+BD,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACnD,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AACxC,CAAC;AAHD,sCAGC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/E,OAAmB,SAAS,CAAC;AAC/B,CAAC;AAJD,wCAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haibun/domain-storage",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "build/domain-storage.js",
|
|
@@ -37,8 +37,5 @@
|
|
|
37
37
|
"prepublishOnly": "tsc -b .",
|
|
38
38
|
"preversion": "npm run lint",
|
|
39
39
|
"version": "npm run format && git add -A src"
|
|
40
|
-
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"ts-jest": "^27.1.3"
|
|
43
40
|
}
|
|
44
|
-
}
|
|
41
|
+
}
|