@naturalcycles/nodejs-lib 13.6.0 → 13.7.1

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/fs/fs2.d.ts CHANGED
@@ -33,6 +33,8 @@ declare class FS2 {
33
33
  writeJsonAsync(filePath: string, data: any, opt?: JsonOptions): Promise<void>;
34
34
  writeYaml(filePath: string, data: any, opt?: DumpOptions): void;
35
35
  writeYamlAsync(filePath: string, data: any, opt?: DumpOptions): Promise<void>;
36
+ appendFile(filePath: string, data: string | Buffer): void;
37
+ appendFileAsync(filePath: string, data: string | Buffer): Promise<void>;
36
38
  outputJson(filePath: string, data: any, opt?: JsonOptions): void;
37
39
  outputJsonAsync(filePath: string, data: any, opt?: JsonOptions): Promise<void>;
38
40
  outputYaml(filePath: string, data: any, opt?: DumpOptions): void;
@@ -57,6 +59,8 @@ declare class FS2 {
57
59
  * Cautious, underlying Node function is currently Experimental.
58
60
  */
59
61
  copyPathAsync(src: string, dest: string, opt?: fs.CopyOptions): Promise<void>;
62
+ renamePath(src: string, dest: string): void;
63
+ renamePathAsync(src: string, dest: string): Promise<void>;
60
64
  movePath(src: string, dest: string, opt?: fs.CopySyncOptions): void;
61
65
  movePathAsync(src: string, dest: string, opt?: fs.CopyOptions): Promise<void>;
62
66
  fs: typeof fs;
package/dist/fs/fs2.js CHANGED
@@ -105,6 +105,12 @@ class FS2 {
105
105
  const str = js_yaml_1.default.dump(data, opt);
106
106
  await promises_1.default.writeFile(filePath, str);
107
107
  }
108
+ appendFile(filePath, data) {
109
+ node_fs_1.default.appendFileSync(filePath, data);
110
+ }
111
+ async appendFileAsync(filePath, data) {
112
+ await promises_1.default.appendFile(filePath, data);
113
+ }
108
114
  outputJson(filePath, data, opt) {
109
115
  const str = stringify(data, opt);
110
116
  this.outputFile(filePath, str);
@@ -251,6 +257,12 @@ class FS2 {
251
257
  ...opt,
252
258
  });
253
259
  }
260
+ renamePath(src, dest) {
261
+ node_fs_1.default.renameSync(src, dest);
262
+ }
263
+ async renamePathAsync(src, dest) {
264
+ await promises_1.default.rename(src, dest);
265
+ }
254
266
  movePath(src, dest, opt) {
255
267
  this.copyPath(src, dest, opt);
256
268
  this.removePath(src);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { BaseDBEntity, NumberEnum, SavedDBEntity, StringEnum } from '@naturalcycles/js-lib';
2
+ import { BaseDBEntity, NumberEnum, StringEnum } from '@naturalcycles/js-lib';
3
3
  import { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
4
4
  import { NumberSchema } from './number.extensions';
5
5
  import { StringSchema } from './string.extensions';
@@ -92,4 +92,3 @@ export declare const userAgentSchema: StringSchema<string>;
92
92
  export declare const utcOffsetSchema: NumberSchema<number>;
93
93
  export declare const ipAddressSchema: StringSchema<string>;
94
94
  export declare const baseDBEntitySchema: ObjectSchema<BaseDBEntity>;
95
- export declare const savedDBEntitySchema: ObjectSchema<SavedDBEntity>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.savedDBEntitySchema = exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_REGEX = exports.emailSchema = exports.verSchema = exports.unixTimestampMillis2000Schema = exports.unixTimestampMillisSchema = exports.unixTimestamp2000Schema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_REGEX = exports.idBase64UrlSchema = exports.idBase64Schema = exports.idBase62Schema = exports.idSchema = exports.jwtSchema = exports.JWT_REGEX = exports.base64UrlSchema = exports.base64Schema = exports.base62Schema = exports.BASE64URL_REGEX = exports.BASE64_REGEX = exports.BASE62_REGEX = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.numberEnumKeySchema = exports.numberEnumValueSchema = exports.stringEnumKeySchema = exports.stringEnumValueSchema = exports.dateObjectSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchemaTyped = exports.numberSchema = exports.stringSchemaTyped = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
3
+ exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_REGEX = exports.emailSchema = exports.verSchema = exports.unixTimestampMillis2000Schema = exports.unixTimestampMillisSchema = exports.unixTimestamp2000Schema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_REGEX = exports.idBase64UrlSchema = exports.idBase64Schema = exports.idBase62Schema = exports.idSchema = exports.jwtSchema = exports.JWT_REGEX = exports.base64UrlSchema = exports.base64Schema = exports.base62Schema = exports.BASE64URL_REGEX = exports.BASE64_REGEX = exports.BASE62_REGEX = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.numberEnumKeySchema = exports.numberEnumValueSchema = exports.stringEnumKeySchema = exports.stringEnumValueSchema = exports.dateObjectSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchemaTyped = exports.numberSchema = exports.stringSchemaTyped = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  const joi_extensions_1 = require("./joi.extensions");
6
6
  exports.booleanSchema = joi_extensions_1.Joi.boolean();
@@ -126,8 +126,3 @@ exports.baseDBEntitySchema = objectSchema({
126
126
  created: exports.unixTimestamp2000Schema.optional(),
127
127
  updated: exports.unixTimestamp2000Schema.optional(),
128
128
  });
129
- exports.savedDBEntitySchema = objectSchema({
130
- id: exports.stringSchema,
131
- created: exports.unixTimestamp2000Schema,
132
- updated: exports.unixTimestamp2000Schema,
133
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.6.0",
3
+ "version": "13.7.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
package/src/fs/fs2.ts CHANGED
@@ -102,6 +102,14 @@ class FS2 {
102
102
  await fsp.writeFile(filePath, str)
103
103
  }
104
104
 
105
+ appendFile(filePath: string, data: string | Buffer): void {
106
+ fs.appendFileSync(filePath, data)
107
+ }
108
+
109
+ async appendFileAsync(filePath: string, data: string | Buffer): Promise<void> {
110
+ await fsp.appendFile(filePath, data)
111
+ }
112
+
105
113
  outputJson(filePath: string, data: any, opt?: JsonOptions): void {
106
114
  const str = stringify(data, opt)
107
115
  this.outputFile(filePath, str)
@@ -263,6 +271,14 @@ class FS2 {
263
271
  })
264
272
  }
265
273
 
274
+ renamePath(src: string, dest: string): void {
275
+ fs.renameSync(src, dest)
276
+ }
277
+
278
+ async renamePathAsync(src: string, dest: string): Promise<void> {
279
+ await fsp.rename(src, dest)
280
+ }
281
+
266
282
  movePath(src: string, dest: string, opt?: fs.CopySyncOptions): void {
267
283
  this.copyPath(src, dest, opt)
268
284
  this.removePath(src)
@@ -5,7 +5,6 @@ import {
5
5
  _stringEnumValues,
6
6
  BaseDBEntity,
7
7
  NumberEnum,
8
- SavedDBEntity,
9
8
  StringEnum,
10
9
  } from '@naturalcycles/js-lib'
11
10
  import { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi'
@@ -159,9 +158,3 @@ export const baseDBEntitySchema: ObjectSchema<BaseDBEntity> = objectSchema<BaseD
159
158
  created: unixTimestamp2000Schema.optional(),
160
159
  updated: unixTimestamp2000Schema.optional(),
161
160
  })
162
-
163
- export const savedDBEntitySchema = objectSchema<SavedDBEntity>({
164
- id: stringSchema,
165
- created: unixTimestamp2000Schema,
166
- updated: unixTimestamp2000Schema,
167
- })