@prosopo/datasets-fs 0.2.13 → 0.2.14
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/cli/cliCommand.d.ts +1 -1
- package/dist/cli/cliCommand.d.ts.map +1 -1
- package/dist/cli/cliCommand.js.map +1 -1
- package/dist/cli/cliCommandComposite.d.ts +1 -1
- package/dist/cli/cliCommandComposite.d.ts.map +1 -1
- package/dist/cli/cliCommandComposite.js.map +1 -1
- package/dist/commands/flatten.d.ts +1 -1
- package/dist/commands/flatten.d.ts.map +1 -1
- package/dist/commands/flatten.js +4 -3
- package/dist/commands/flatten.js.map +1 -1
- package/dist/commands/generate.d.ts +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +2 -2
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/generateV1.d.ts +1 -1
- package/dist/commands/generateV1.d.ts.map +1 -1
- package/dist/commands/generateV1.js +4 -3
- package/dist/commands/generateV1.js.map +1 -1
- package/dist/commands/generateV2.d.ts +1 -1
- package/dist/commands/generateV2.d.ts.map +1 -1
- package/dist/commands/generateV2.js +4 -3
- package/dist/commands/generateV2.js.map +1 -1
- package/dist/commands/get.d.ts +1 -1
- package/dist/commands/get.d.ts.map +1 -1
- package/dist/commands/get.js +2 -2
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/labels.d.ts +1 -1
- package/dist/commands/labels.d.ts.map +1 -1
- package/dist/commands/labels.js +1 -1
- package/dist/commands/labels.js.map +1 -1
- package/dist/commands/relocate.d.ts +1 -1
- package/dist/commands/relocate.d.ts.map +1 -1
- package/dist/commands/relocate.js +3 -2
- package/dist/commands/relocate.js.map +1 -1
- package/dist/commands/resize.d.ts +1 -1
- package/dist/commands/resize.d.ts.map +1 -1
- package/dist/commands/resize.js +3 -3
- package/dist/commands/resize.js.map +1 -1
- package/dist/tests/lodash.test.d.ts +2 -0
- package/dist/tests/lodash.test.d.ts.map +1 -0
- package/dist/tests/lodash.test.js +39 -0
- package/dist/tests/lodash.test.js.map +1 -0
- package/dist/tests/mocked.test.js +1 -1
- package/dist/tests/mocked.test.js.map +1 -1
- package/dist/utils/input.d.ts +1 -1
- package/dist/utils/input.d.ts.map +1 -1
- package/dist/utils/input.js +1 -1
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/inputOutput.d.ts +1 -1
- package/dist/utils/inputOutput.d.ts.map +1 -1
- package/dist/utils/inputOutput.js.map +1 -1
- package/dist/utils/output.d.ts +6 -6
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +5 -5
- package/dist/utils/output.js.map +1 -1
- package/package.json +4 -4
- package/src/cli/cliCommand.ts +1 -1
- package/src/cli/cliCommandComposite.ts +1 -1
- package/src/commands/flatten.ts +4 -3
- package/src/commands/generate.ts +2 -2
- package/src/commands/generateV1.ts +4 -3
- package/src/commands/generateV2.ts +4 -3
- package/src/commands/get.ts +2 -2
- package/src/commands/labels.ts +2 -2
- package/src/commands/relocate.ts +3 -2
- package/src/commands/resize.ts +3 -3
- package/src/tests/lodash.test.ts +40 -0
- package/src/tests/mocked.test.ts +1 -1
- package/src/utils/input.ts +1 -1
- package/src/utils/inputOutput.ts +1 -1
- package/src/utils/output.ts +6 -6
- package/tsconfig.tsbuildinfo +1 -1
package/dist/utils/input.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjD,eAAO,MAAM,eAAe;;;;;;EAE1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,qBAAa,eAAe,CAAC,CAAC,SAAS,OAAO,eAAe,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAChE,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;IAWJ,MAAM,CAAC,IAAI,EAAE,SAAS;CAQ/C"}
|
package/dist/utils/input.js
CHANGED
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAIF,MAAM,OAAO,eAAkD,SAAQ,UAAa;IAChE,YAAY;QACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,cAAc;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,UAAU;QACtB,OAAO;YACH,KAAK,EAAE;gBACH,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,gBAAgB;aAChC;SACJ,CAAA;IACL,CAAC;IAEe,KAAK,CAAC,MAAM,CAAC,IAAe;QACxC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACjC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACxB,mBAAmB;QACnB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAA;SACxG;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAInE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAA0C,CAAA;AAE5E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE,8BAAsB,qBAAqB,CAAC,CAAC,SAAS,OAAO,qBAAqB,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;;CAIjH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;AAI5E,MAAM,OAAgB,qBAA8D,SAAQ,mBAAsB;IAC9G;QACI,KAAK,CAAC,CAAC,IAAI,eAAe,EAAK,EAAE,IAAI,gBAAgB,EAAK,CAAC,CAAC,CAAA;IAChE,CAAC;CACJ"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
2
|
import { CliCommand } from '../cli/cliCommand.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare const OutputArgsSchema:
|
|
5
|
-
output:
|
|
6
|
-
overwrite:
|
|
7
|
-
}, "strip",
|
|
3
|
+
import { infer as zInfer } from 'zod';
|
|
4
|
+
export declare const OutputArgsSchema: import("zod").ZodObject<{
|
|
5
|
+
output: import("zod").ZodString;
|
|
6
|
+
overwrite: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
7
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
8
8
|
output: string;
|
|
9
9
|
overwrite?: boolean | undefined;
|
|
10
10
|
}, {
|
|
11
11
|
output: string;
|
|
12
12
|
overwrite?: boolean | undefined;
|
|
13
13
|
}>;
|
|
14
|
-
export type OutputArgs =
|
|
14
|
+
export type OutputArgs = zInfer<typeof OutputArgsSchema>;
|
|
15
15
|
export declare class OutputCliCommand<T extends typeof OutputArgsSchema> extends CliCommand<T> {
|
|
16
16
|
#private;
|
|
17
17
|
outputExists(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAA2B,KAAK,IAAI,MAAM,EAAE,MAAM,KAAK,CAAA;AAI9D,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAExD,qBAAa,gBAAgB,CAAC,CAAC,SAAS,OAAO,gBAAgB,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;;IAG3E,YAAY;IAIH,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;;;;;;;IAeJ,MAAM,CAAC,IAAI,EAAE,UAAU;IAkBvB,IAAI,CAAC,IAAI,EAAE,UAAU;CAS9C"}
|
package/dist/utils/output.js
CHANGED
|
@@ -2,12 +2,12 @@ var _OutputCliCommand_outputExists;
|
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { CliCommand } from '../cli/cliCommand.js';
|
|
4
4
|
import { ProsopoEnvError } from '@prosopo/common';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { boolean, object, string } from 'zod';
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash';
|
|
7
7
|
import fs from 'fs';
|
|
8
|
-
export const OutputArgsSchema =
|
|
9
|
-
output:
|
|
10
|
-
overwrite:
|
|
8
|
+
export const OutputArgsSchema = object({
|
|
9
|
+
output: string(),
|
|
10
|
+
overwrite: boolean().optional(),
|
|
11
11
|
});
|
|
12
12
|
export class OutputCliCommand extends CliCommand {
|
|
13
13
|
constructor() {
|
package/dist/utils/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,KAAK,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE;IAChB,SAAS,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAA;AAIF,MAAM,OAAO,gBAAoD,SAAQ,UAAa;IAAtF;;QACI,yCAAgB,KAAK,EAAA;IAsDzB,CAAC;IApDU,YAAY;QACf,OAAO,uBAAA,IAAI,sCAAc,CAAA;IAC7B,CAAC;IAEe,YAAY;QACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,cAAc;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,UAAU;QACtB,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE;YACtC,MAAM,EAAE;gBACJ,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,iBAAiB;aACjC;YACD,SAAS,EAAE;gBACP,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,0DAA0D;aAC1E;SACJ,CAAC,CAAA;IACN,CAAC;IAEe,KAAK,CAAC,MAAM,CAAC,IAAgB;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;QAClC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAExB,uCAAuC;QACvC,uBAAA,IAAI,kCAAiB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAA,CAAA;QAE/C,kDAAkD;QAClD,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACjB,MAAM,IAAI,eAAe,CACrB,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,MAAM,EAAE,CAAC,EACvD,wBAAwB,CAC3B,CAAA;aACJ;SACJ;IACL,CAAC;IAEe,KAAK,CAAC,IAAI,CAAC,IAAgB;QACvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAC/B,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;YACvC,oDAAoD;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;YAChD,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;SAC9C;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/datasets-fs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@polkadot/util": "^12.3.2",
|
|
31
|
-
"@prosopo/common": "0.2.
|
|
32
|
-
"@prosopo/types": "0.2.
|
|
33
|
-
"@prosopo/util": "0.2.
|
|
31
|
+
"@prosopo/common": "0.2.14",
|
|
32
|
+
"@prosopo/types": "0.2.14",
|
|
33
|
+
"@prosopo/util": "0.2.14",
|
|
34
34
|
"bcrypt": "^5.1.0",
|
|
35
35
|
"cli-progress": "^3.12.0",
|
|
36
36
|
"es-main": "^1.2.0",
|
package/src/cli/cliCommand.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { Loggable } from '@prosopo/common'
|
|
2
3
|
import { Options } from 'yargs'
|
|
3
4
|
import { kebabCase } from '@prosopo/util'
|
|
4
|
-
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
export abstract class CliCommand<T extends z.ZodTypeAny> extends Loggable {
|
|
7
7
|
// get the options for the CLI
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CliCommand, CliCommandAny } from './cliCommand.js'
|
|
2
3
|
import { Options } from 'yargs'
|
|
3
|
-
import { z } from 'zod'
|
|
4
4
|
|
|
5
5
|
export abstract class CliCommandComposite<T extends z.ZodTypeAny> extends CliCommand<T> {
|
|
6
6
|
#commands: CliCommandAny[] = []
|
package/src/commands/flatten.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaItemTypes, Data, DataSchema, LabelledItem } from '@prosopo/types'
|
|
2
3
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
3
|
-
import { at
|
|
4
|
+
import { at } from '@prosopo/util'
|
|
4
5
|
import { blake2b } from '@noble/hashes/blake2b'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
|
+
import { u8aToHex } from '@polkadot/util/u8a'
|
|
7
8
|
import cliProgress from 'cli-progress'
|
|
8
9
|
import fs from 'fs'
|
|
9
10
|
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { DataSchema, Item, LabelledDataSchema, LabelledItem, LabelsContainerSchema } from '@prosopo/types'
|
|
2
3
|
import { OutputArgsSchema, OutputCliCommand } from '../utils/output.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { lodash, setSeedGlobal } from '@prosopo/util'
|
|
5
|
-
import { z } from 'zod'
|
|
5
|
+
import { lodash, setSeedGlobal } from '@prosopo/util/lodash'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
|
8
8
|
export const ArgsSchema = OutputArgsSchema.extend({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaTypes, CaptchaWithoutId, Captchas, CaptchasContainerSchema, Item, RawSolution } from '@prosopo/types'
|
|
2
3
|
import { Generate, ArgsSchema as GenerateArgsSchema } from './generate.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { at, get
|
|
5
|
-
import { blake2AsHex } from '@polkadot/util-crypto'
|
|
6
|
-
import {
|
|
5
|
+
import { at, get } from '@prosopo/util'
|
|
6
|
+
import { blake2AsHex } from '@polkadot/util-crypto/blake2'
|
|
7
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
8
|
import bcrypt from 'bcrypt'
|
|
8
9
|
import cliProgress from 'cli-progress'
|
|
9
10
|
import fs from 'fs'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaTypes, CaptchaWithoutId, Captchas, CaptchasContainerSchema, Item, RawSolution } from '@prosopo/types'
|
|
2
3
|
import { Generate, ArgsSchema as GenerateArgsSchema } from './generate.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { at, get
|
|
5
|
-
import { blake2AsHex } from '@polkadot/util-crypto'
|
|
6
|
-
import {
|
|
5
|
+
import { at, get } from '@prosopo/util'
|
|
6
|
+
import { blake2AsHex } from '@polkadot/util-crypto/blake2'
|
|
7
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
8
|
import bcrypt from 'bcrypt'
|
|
8
9
|
import cliProgress from 'cli-progress'
|
|
9
10
|
import fs from 'fs'
|
package/src/commands/get.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputArgsSchema, InputCliCommand } from '../utils/input.js'
|
|
2
3
|
import { get } from '@prosopo/util'
|
|
3
|
-
import { lodash } from '@prosopo/util'
|
|
4
|
-
import { z } from 'zod'
|
|
4
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
5
5
|
import cliProgress from 'cli-progress'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
package/src/commands/labels.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
2
3
|
import { LabelledDataSchema, LabelledItem } from '@prosopo/types'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { lodash } from '@prosopo/util'
|
|
5
|
-
import { z } from 'zod'
|
|
5
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
|
8
8
|
export const ArgsSchema = InputOutputArgsSchema.extend({})
|
package/src/commands/relocate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
2
|
-
import { get
|
|
3
|
-
import {
|
|
3
|
+
import { get } from '@prosopo/util'
|
|
4
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
4
5
|
import fs from 'fs'
|
|
5
6
|
|
|
6
7
|
export const ArgsSchema = InputOutputArgsSchema.extend({
|
package/src/commands/resize.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { Data, DataSchema, Item } from '@prosopo/types'
|
|
2
3
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
5
|
import { blake2b } from '@noble/hashes/blake2b'
|
|
5
|
-
import { lodash } from '@prosopo/util'
|
|
6
|
-
import { u8aToHex } from '@polkadot/util'
|
|
7
|
-
import { z } from 'zod'
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
|
+
import { u8aToHex } from '@polkadot/util/u8a'
|
|
8
8
|
import cliProgress from 'cli-progress'
|
|
9
9
|
import fs from 'fs'
|
|
10
10
|
import sharp from 'sharp'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { describe, expect, test } from 'vitest'
|
|
15
|
+
import { rng, seedLodash } from '@prosopo/util/lodash'
|
|
16
|
+
|
|
17
|
+
describe('rng', () => {
|
|
18
|
+
test('generates random numbers using a seed', () => {
|
|
19
|
+
const seed = 0
|
|
20
|
+
const rand = rng(seed)
|
|
21
|
+
const expected = [-1681090547, 408334984, 788430095, 3233831872, 963300000, -299378919, 97582850]
|
|
22
|
+
for (let i = 0; i < expected.length; i++) {
|
|
23
|
+
expect(rand.int()).to.equal(expected[i])
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('seeded_lodash', () => {
|
|
29
|
+
test('shuffles an array using a seed', () => {
|
|
30
|
+
let array = [1, 2, 3, 4, 5]
|
|
31
|
+
const seed = 0
|
|
32
|
+
const _ = seedLodash(seed)
|
|
33
|
+
array = _.shuffle(array)
|
|
34
|
+
expect(array).to.deep.equal([4, 2, 1, 3, 5])
|
|
35
|
+
array = _.shuffle(array)
|
|
36
|
+
expect(array).to.deep.equal([3, 4, 1, 5, 2])
|
|
37
|
+
array = _.shuffle(array)
|
|
38
|
+
expect(array).to.deep.equal([3, 4, 5, 2, 1])
|
|
39
|
+
})
|
|
40
|
+
})
|
package/src/tests/mocked.test.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Resize } from '../commands/resize.js'
|
|
|
8
8
|
import { afterAll, beforeAll, describe, test } from 'vitest'
|
|
9
9
|
import { blake2b } from '@noble/hashes/blake2b'
|
|
10
10
|
import { captchasEqFs, fsEq, fsWalk, restoreRepoDir, substituteRepoDir } from './utils.js'
|
|
11
|
-
import { u8aToHex } from '@polkadot/util'
|
|
11
|
+
import { u8aToHex } from '@polkadot/util/u8a'
|
|
12
12
|
import fs from 'fs'
|
|
13
13
|
import sharp from 'sharp'
|
|
14
14
|
|
package/src/utils/input.ts
CHANGED
package/src/utils/inputOutput.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CliCommandComposite } from '../cli/cliCommandComposite.js'
|
|
2
3
|
import { InputArgsSchema, InputCliCommand } from './input.js'
|
|
3
4
|
import { OutputArgsSchema, OutputCliCommand } from './output.js'
|
|
4
|
-
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
export const InputOutputArgsSchema = InputArgsSchema.merge(OutputArgsSchema)
|
|
7
7
|
|
package/src/utils/output.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { CliCommand } from '../cli/cliCommand.js'
|
|
2
2
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { boolean, object, string, infer as zInfer } from 'zod'
|
|
4
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
5
5
|
import fs from 'fs'
|
|
6
6
|
|
|
7
|
-
export const OutputArgsSchema =
|
|
8
|
-
output:
|
|
9
|
-
overwrite:
|
|
7
|
+
export const OutputArgsSchema = object({
|
|
8
|
+
output: string(),
|
|
9
|
+
overwrite: boolean().optional(),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
export type OutputArgs =
|
|
12
|
+
export type OutputArgs = zInfer<typeof OutputArgsSchema>
|
|
13
13
|
|
|
14
14
|
export class OutputCliCommand<T extends typeof OutputArgsSchema> extends CliCommand<T> {
|
|
15
15
|
#outputExists = false
|