@prosopo/datasets-fs 2.1.6 → 2.1.8

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.
Files changed (93) hide show
  1. package/package.json +6 -6
  2. package/dist/cjs/cli/cli.cjs +0 -58
  3. package/dist/cjs/index.cjs +0 -4
  4. package/dist/cli/cli.d.ts +0 -9
  5. package/dist/cli/cli.d.ts.map +0 -1
  6. package/dist/cli/cli.js +0 -58
  7. package/dist/cli/cli.js.map +0 -1
  8. package/dist/cli/cliCommand.d.ts +0 -17
  9. package/dist/cli/cliCommand.d.ts.map +0 -1
  10. package/dist/cli/cliCommand.js +0 -28
  11. package/dist/cli/cliCommand.js.map +0 -1
  12. package/dist/cli/cliCommandComposite.d.ts +0 -14
  13. package/dist/cli/cliCommandComposite.d.ts.map +0 -1
  14. package/dist/cli/cliCommandComposite.js +0 -32
  15. package/dist/cli/cliCommandComposite.js.map +0 -1
  16. package/dist/cli.d.ts +0 -2
  17. package/dist/cli.d.ts.map +0 -1
  18. package/dist/cli.js +0 -34
  19. package/dist/cli.js.map +0 -1
  20. package/dist/commands/flatten.d.ts +0 -59
  21. package/dist/commands/flatten.d.ts.map +0 -1
  22. package/dist/commands/flatten.js +0 -96
  23. package/dist/commands/flatten.js.map +0 -1
  24. package/dist/commands/generate.d.ts +0 -115
  25. package/dist/commands/generate.d.ts.map +0 -1
  26. package/dist/commands/generate.js +0 -150
  27. package/dist/commands/generate.js.map +0 -1
  28. package/dist/commands/generateV1.d.ts +0 -179
  29. package/dist/commands/generateV1.d.ts.map +0 -1
  30. package/dist/commands/generateV1.js +0 -169
  31. package/dist/commands/generateV1.js.map +0 -1
  32. package/dist/commands/generateV2.d.ts +0 -189
  33. package/dist/commands/generateV2.d.ts.map +0 -1
  34. package/dist/commands/generateV2.js +0 -200
  35. package/dist/commands/generateV2.js.map +0 -1
  36. package/dist/commands/get.d.ts +0 -35
  37. package/dist/commands/get.d.ts.map +0 -1
  38. package/dist/commands/get.js +0 -79
  39. package/dist/commands/get.js.map +0 -1
  40. package/dist/commands/labels.d.ts +0 -47
  41. package/dist/commands/labels.d.ts.map +0 -1
  42. package/dist/commands/labels.js +0 -48
  43. package/dist/commands/labels.js.map +0 -1
  44. package/dist/commands/relocate.d.ts +0 -71
  45. package/dist/commands/relocate.d.ts.map +0 -1
  46. package/dist/commands/relocate.js +0 -75
  47. package/dist/commands/relocate.js.map +0 -1
  48. package/dist/commands/resize.d.ts +0 -69
  49. package/dist/commands/resize.d.ts.map +0 -1
  50. package/dist/commands/resize.js +0 -112
  51. package/dist/commands/resize.js.map +0 -1
  52. package/dist/dummy.d.ts +0 -2
  53. package/dist/dummy.d.ts.map +0 -1
  54. package/dist/dummy.js +0 -28
  55. package/dist/dummy.js.map +0 -1
  56. package/dist/index.d.ts +0 -2
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/index.js +0 -2
  59. package/dist/index.js.map +0 -1
  60. package/dist/tests/data/flat_resized/labels.json +0 -13
  61. package/dist/tests/data/flat_resized/relocated_data.json +0 -364
  62. package/dist/tests/lodash.test.d.ts +0 -2
  63. package/dist/tests/lodash.test.d.ts.map +0 -1
  64. package/dist/tests/lodash.test.js +0 -26
  65. package/dist/tests/lodash.test.js.map +0 -1
  66. package/dist/tests/lodash.unit.test.d.ts +0 -2
  67. package/dist/tests/lodash.unit.test.d.ts.map +0 -1
  68. package/dist/tests/lodash.unit.test.js +0 -29
  69. package/dist/tests/lodash.unit.test.js.map +0 -1
  70. package/dist/tests/mocked.test.d.ts +0 -2
  71. package/dist/tests/mocked.test.d.ts.map +0 -1
  72. package/dist/tests/mocked.test.js +0 -247
  73. package/dist/tests/mocked.test.js.map +0 -1
  74. package/dist/tests/mocked.unit.test.d.ts +0 -2
  75. package/dist/tests/mocked.unit.test.d.ts.map +0 -1
  76. package/dist/tests/mocked.unit.test.js +0 -253
  77. package/dist/tests/mocked.unit.test.js.map +0 -1
  78. package/dist/tests/utils.d.ts +0 -35
  79. package/dist/tests/utils.d.ts.map +0 -1
  80. package/dist/tests/utils.js +0 -101
  81. package/dist/tests/utils.js.map +0 -1
  82. package/dist/utils/input.d.ts +0 -24
  83. package/dist/utils/input.d.ts.map +0 -1
  84. package/dist/utils/input.js +0 -35
  85. package/dist/utils/input.js.map +0 -1
  86. package/dist/utils/inputOutput.d.ts +0 -21
  87. package/dist/utils/inputOutput.d.ts.map +0 -1
  88. package/dist/utils/inputOutput.js +0 -10
  89. package/dist/utils/inputOutput.js.map +0 -1
  90. package/dist/utils/output.d.ts +0 -36
  91. package/dist/utils/output.d.ts.map +0 -1
  92. package/dist/utils/output.js +0 -62
  93. package/dist/utils/output.js.map +0 -1
@@ -1,247 +0,0 @@
1
- import { CaptchasContainerSchema, DataSchema } from '@prosopo/types';
2
- import { Flatten } from '../commands/flatten.js';
3
- import { GenerateV1 } from '../commands/generateV1.js';
4
- import { GenerateV2 } from '../commands/generateV2.js';
5
- import { Labels } from '../commands/labels.js';
6
- import { Relocate } from '../commands/relocate.js';
7
- import { Resize } from '../commands/resize.js';
8
- import { afterAll, beforeAll, describe, test } from 'vitest';
9
- import { blake2b } from '@noble/hashes/blake2b';
10
- import { captchasEqFs, fsEq, fsWalk, restoreRepoDir, substituteRepoDir } from './utils.js';
11
- import { getRootDir, getTestResultsDir } from '@prosopo/config';
12
- import { u8aToHex } from '@polkadot/util/u8a';
13
- import fs from 'fs';
14
- import path from 'path';
15
- import sharp from 'sharp';
16
- describe('dataset commands', () => {
17
- const pkgDir = path.relative(getRootDir(), __dirname);
18
- const pkgInternalPath = pkgDir.replace(`${__dirname}/`, '');
19
- const testResultsDir = `${getTestResultsDir()}/${pkgInternalPath}`;
20
- beforeAll(() => {
21
- substituteRepoDir();
22
- fs.mkdirSync(`${testResultsDir}`, { recursive: true });
23
- });
24
- afterAll(() => {
25
- restoreRepoDir();
26
- if (fs.existsSync(`${testResultsDir}`)) {
27
- fs.rmdirSync(`${testResultsDir}`, { recursive: true });
28
- }
29
- });
30
- test('labels', async () => {
31
- const input = `${__dirname}/data/flat_resized/data.json`;
32
- const output = `${testResultsDir}/labels.json`;
33
- const labels = new Labels();
34
- labels.logger.setLogLevel('error');
35
- await labels.exec({
36
- input,
37
- output,
38
- });
39
- fsEq(output, `${__dirname}/data/flat_resized/labels.json`);
40
- const content = fs.readFileSync(output).toString();
41
- const labelsJson = JSON.parse(content.toString());
42
- const foundLabels = labelsJson.labels;
43
- const categories = fs.readdirSync(`${__dirname}/data/hierarchical`);
44
- if (JSON.stringify(foundLabels) !== JSON.stringify(categories)) {
45
- throw new Error(`expected ${categories} but found ${foundLabels}`);
46
- }
47
- });
48
- test('generate v2', async () => {
49
- const input = `${__dirname}/data/flat_resized/data.json`;
50
- const output = `${testResultsDir}/captchas_v2.json`;
51
- const minIncorrect = 1;
52
- const minCorrect = 1;
53
- const minLabelled = 2;
54
- const maxLabelled = 7;
55
- const generate = new GenerateV2();
56
- generate.logger.setLogLevel('error');
57
- await generate.exec({
58
- labelled: input,
59
- unlabelled: input,
60
- overwrite: true,
61
- output,
62
- count: 100,
63
- seed: 0,
64
- minIncorrect,
65
- minCorrect,
66
- minLabelled,
67
- maxLabelled,
68
- allowDuplicates: true,
69
- });
70
- if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v2.json`)) {
71
- throw new Error(`captchas not equal`);
72
- }
73
- const content = fs.readFileSync(output).toString();
74
- const captchasJson = JSON.parse(content.toString());
75
- const captchas = CaptchasContainerSchema.parse(captchasJson);
76
- for (const captcha of captchas.captchas) {
77
- const solutions = captcha.solution;
78
- const unlabelled = captcha.unlabelled;
79
- if (solutions === undefined || unlabelled === undefined) {
80
- console.log(captcha);
81
- throw new Error(`solutions or unlabelled array is undefined`);
82
- }
83
- for (const solution of solutions) {
84
- if (unlabelled.includes(solution)) {
85
- throw new Error(`solution ${solution} is also in unlabelled array`);
86
- }
87
- }
88
- const nCorrect = solutions.length;
89
- const nUnlabelled = unlabelled.length;
90
- const nIncorrect = 9 - nCorrect - nUnlabelled;
91
- const nLabelled = nCorrect + nIncorrect;
92
- if (nCorrect < minCorrect) {
93
- throw new Error(`expected at least ${minCorrect} correct but found ${nCorrect}`);
94
- }
95
- if (nIncorrect < minIncorrect) {
96
- throw new Error(`expected at least ${minIncorrect} incorrect but found ${nIncorrect}`);
97
- }
98
- if (nLabelled < minLabelled) {
99
- throw new Error(`expected at least ${minLabelled} labelled but found ${nLabelled}`);
100
- }
101
- if (nLabelled > maxLabelled) {
102
- throw new Error(`expected at most ${maxLabelled} labelled but found ${nLabelled}`);
103
- }
104
- if (nUnlabelled !== 9 - nLabelled) {
105
- throw new Error(`expected ${9 - nLabelled} unlabelled but found ${nUnlabelled}`);
106
- }
107
- }
108
- });
109
- test('generate v1', async () => {
110
- const input = `${__dirname}/data/flat_resized/data.json`;
111
- const output = `${testResultsDir}/captchas_v1.json`;
112
- const generate = new GenerateV1();
113
- generate.logger.setLogLevel('error');
114
- await generate.exec({
115
- labelled: input,
116
- unlabelled: input,
117
- overwrite: true,
118
- output,
119
- solved: 50,
120
- unsolved: 50,
121
- seed: 0,
122
- minCorrect: 1,
123
- maxCorrect: 6,
124
- allowDuplicates: true,
125
- });
126
- if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v1.json`)) {
127
- throw new Error(`captchas not equal`);
128
- }
129
- });
130
- test('resizes data', async () => {
131
- const input = `${__dirname}/data/flat/data.json`;
132
- const output = `${testResultsDir}/flat_resized`;
133
- const resize = new Resize();
134
- resize.logger.setLogLevel('error');
135
- await resize.exec({
136
- input,
137
- output,
138
- overwrite: true,
139
- square: true,
140
- size: 128,
141
- });
142
- const expected = `${__dirname}/data/flat_resized`;
143
- fsEq(output, expected);
144
- for (const pth of fsWalk(output)) {
145
- if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
146
- continue;
147
- }
148
- const image = sharp(pth);
149
- const metadata = await image.metadata();
150
- if (metadata.width !== 128 || metadata.height !== 128) {
151
- throw new Error(`image ${pth} is not 128x128`);
152
- }
153
- }
154
- });
155
- test('relocates data', async () => {
156
- const input = `${__dirname}/data/flat_resized/data.json`;
157
- const output = `${testResultsDir}/relocated_data.json`;
158
- const relocate = new Relocate();
159
- relocate.logger.setLogLevel('error');
160
- await relocate.exec({
161
- input,
162
- output,
163
- overwrite: true,
164
- to: 'newwebsite.com',
165
- from: '${repo}',
166
- });
167
- const expected = `${__dirname}/data/flat_resized/relocated_data.json`;
168
- fsEq(output, expected);
169
- });
170
- test('flattens hierarchical data', async () => {
171
- const input = `${__dirname}/data/hierarchical`;
172
- const output = `${testResultsDir}/flat`;
173
- const flatten = new Flatten();
174
- flatten.logger.setLogLevel('error');
175
- await flatten.exec({
176
- input,
177
- output,
178
- overwrite: true,
179
- });
180
- const expected = `${__dirname}/data/flat`;
181
- fsEq(output, expected);
182
- const content = fs.readFileSync(`${output}/data.json`).toString();
183
- const dataJson = JSON.parse(content.toString());
184
- const data = DataSchema.parse(dataJson);
185
- let hierCount = 0;
186
- for (const pth of fsWalk(input)) {
187
- if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
188
- continue;
189
- }
190
- hierCount++;
191
- const category = pth.split('/').slice(-2)[0];
192
- const content = fs.readFileSync(pth);
193
- let name = '';
194
- for (const pth2 of fsWalk(output)) {
195
- if (!fs.statSync(pth2).isFile()) {
196
- continue;
197
- }
198
- const content2 = fs.readFileSync(pth2);
199
- if (content.equals(content2)) {
200
- const str = pth2.split('/').slice(-1)[0];
201
- if (str === undefined) {
202
- throw new Error(`unable to parse ${pth2}`);
203
- }
204
- name = str;
205
- break;
206
- }
207
- }
208
- if (!name) {
209
- throw new Error(`unable to find image ${pth} in output`);
210
- }
211
- const item = data.items.find((item) => {
212
- const name2 = item.data.split('/').slice(-1)[0];
213
- if (name2 !== name) {
214
- return false;
215
- }
216
- return true;
217
- });
218
- if (item === undefined) {
219
- throw new Error(`unable to find image ${pth} in data.json`);
220
- }
221
- if (item.label != category) {
222
- throw new Error(`expected ${category} but found ${item.label}`);
223
- }
224
- if (item.type !== 'image') {
225
- throw new Error(`expected image type but found ${item.type}`);
226
- }
227
- if (item.hash !== name.split('.')[0]) {
228
- throw new Error(`expected ${name.split('.')[0]} hash but found ${item.hash}`);
229
- }
230
- const hash = u8aToHex(blake2b(content));
231
- if (item.hash !== hash) {
232
- throw new Error(`expected ${hash} hash but found ${item.hash}`);
233
- }
234
- }
235
- let flatCount = 0;
236
- for (const pth of fsWalk(output)) {
237
- if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
238
- continue;
239
- }
240
- flatCount++;
241
- }
242
- if (hierCount !== flatCount) {
243
- throw new Error(`expected ${hierCount} images but found ${flatCount}`);
244
- }
245
- });
246
- });
247
- //# sourceMappingURL=mocked.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mocked.test.js","sourceRoot":"","sources":["../../src/tests/mocked.test.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,iBA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AAE,CAAA;SACd;QAGD,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,YAAY,SAAS,qBAAqB,SAAS,EAAE,CAAC,CAAA;SACzE;IACL,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mocked.unit.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mocked.unit.test.d.ts","sourceRoot":"","sources":["../../src/tests/mocked.unit.test.ts"],"names":[],"mappings":""}
@@ -1,253 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { blake2b } from "@noble/hashes/blake2b";
4
- import { u8aToHex } from "@polkadot/util/u8a";
5
- import { getRootDir, getTestResultsDir } from "@prosopo/config";
6
- import { CaptchasContainerSchema, DataSchema } from "@prosopo/types";
7
- import sharp from "sharp";
8
- import { afterAll, beforeAll, describe, test } from "vitest";
9
- import { Flatten } from "../commands/flatten.js";
10
- import { GenerateV1 } from "../commands/generateV1.js";
11
- import { GenerateV2 } from "../commands/generateV2.js";
12
- import { Labels } from "../commands/labels.js";
13
- import { Relocate } from "../commands/relocate.js";
14
- import { Resize } from "../commands/resize.js";
15
- import { captchasEqFs, fsEq, fsWalk, restoreRepoDir, substituteRepoDir, } from "./utils.js";
16
- describe("dataset commands", () => {
17
- const pkgDir = path.relative(getRootDir(), __dirname);
18
- const pkgInternalPath = pkgDir.replace(`${__dirname}/`, "");
19
- const testResultsDir = `${getTestResultsDir()}/${pkgInternalPath}`;
20
- beforeAll(() => {
21
- substituteRepoDir();
22
- fs.mkdirSync(`${testResultsDir}`, { recursive: true });
23
- });
24
- afterAll(() => {
25
- restoreRepoDir();
26
- if (fs.existsSync(`${testResultsDir}`)) {
27
- fs.rmdirSync(`${testResultsDir}`, { recursive: true });
28
- }
29
- });
30
- test("labels", async () => {
31
- const input = `${__dirname}/data/flat_resized/data.json`;
32
- const output = `${testResultsDir}/labels.json`;
33
- const labels = new Labels();
34
- labels.logger.setLogLevel("error");
35
- await labels.exec({
36
- input,
37
- output,
38
- });
39
- fsEq(output, `${__dirname}/data/flat_resized/labels.json`);
40
- const content = fs.readFileSync(output).toString();
41
- const labelsJson = JSON.parse(content.toString());
42
- const foundLabels = labelsJson.labels;
43
- const categories = fs.readdirSync(`${__dirname}/data/hierarchical`);
44
- if (JSON.stringify(foundLabels) !== JSON.stringify(categories)) {
45
- throw new Error(`expected ${categories} but found ${foundLabels}`);
46
- }
47
- });
48
- test("generate v2", async () => {
49
- const input = `${__dirname}/data/flat_resized/data.json`;
50
- const output = `${testResultsDir}/captchas_v2.json`;
51
- const minIncorrect = 1;
52
- const minCorrect = 1;
53
- const minLabelled = 2;
54
- const maxLabelled = 7;
55
- const generate = new GenerateV2();
56
- generate.logger.setLogLevel("error");
57
- await generate.exec({
58
- labelled: input,
59
- unlabelled: input,
60
- overwrite: true,
61
- output,
62
- count: 100,
63
- seed: 0,
64
- minIncorrect,
65
- minCorrect,
66
- minLabelled,
67
- maxLabelled,
68
- allowDuplicates: true,
69
- });
70
- if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v2.json`)) {
71
- throw new Error("captchas not equal");
72
- }
73
- const content = fs.readFileSync(output).toString();
74
- const captchasJson = JSON.parse(content.toString());
75
- const captchas = CaptchasContainerSchema.parse(captchasJson);
76
- for (const captcha of captchas.captchas) {
77
- const solutions = captcha.solution;
78
- const unlabelled = captcha.unlabelled;
79
- if (solutions === undefined || unlabelled === undefined) {
80
- console.log(captcha);
81
- throw new Error("solutions or unlabelled array is undefined");
82
- }
83
- for (const solution of solutions) {
84
- if (unlabelled.includes(solution)) {
85
- throw new Error(`solution ${solution} is also in unlabelled array`);
86
- }
87
- }
88
- const nCorrect = solutions.length;
89
- const nUnlabelled = unlabelled.length;
90
- const nIncorrect = 9 - nCorrect - nUnlabelled;
91
- const nLabelled = nCorrect + nIncorrect;
92
- if (nCorrect < minCorrect) {
93
- throw new Error(`expected at least ${minCorrect} correct but found ${nCorrect}`);
94
- }
95
- if (nIncorrect < minIncorrect) {
96
- throw new Error(`expected at least ${minIncorrect} incorrect but found ${nIncorrect}`);
97
- }
98
- if (nLabelled < minLabelled) {
99
- throw new Error(`expected at least ${minLabelled} labelled but found ${nLabelled}`);
100
- }
101
- if (nLabelled > maxLabelled) {
102
- throw new Error(`expected at most ${maxLabelled} labelled but found ${nLabelled}`);
103
- }
104
- if (nUnlabelled !== 9 - nLabelled) {
105
- throw new Error(`expected ${9 - nLabelled} unlabelled but found ${nUnlabelled}`);
106
- }
107
- }
108
- });
109
- test("generate v1", async () => {
110
- const input = `${__dirname}/data/flat_resized/data.json`;
111
- const output = `${testResultsDir}/captchas_v1.json`;
112
- const generate = new GenerateV1();
113
- generate.logger.setLogLevel("error");
114
- await generate.exec({
115
- labelled: input,
116
- unlabelled: input,
117
- overwrite: true,
118
- output,
119
- solved: 50,
120
- unsolved: 50,
121
- seed: 0,
122
- minCorrect: 1,
123
- maxCorrect: 6,
124
- allowDuplicates: true,
125
- });
126
- if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v1.json`)) {
127
- throw new Error("captchas not equal");
128
- }
129
- });
130
- test("resizes data", async () => {
131
- const input = `${__dirname}/data/flat/data.json`;
132
- const output = `${testResultsDir}/flat_resized`;
133
- const resize = new Resize();
134
- resize.logger.setLogLevel("error");
135
- await resize.exec({
136
- input,
137
- output,
138
- overwrite: true,
139
- square: true,
140
- size: 128,
141
- });
142
- const expected = `${__dirname}/data/flat_resized`;
143
- fsEq(output, expected);
144
- for (const pth of fsWalk(output)) {
145
- if (!pth.endsWith(".jpg") &&
146
- !pth.endsWith(".jpeg") &&
147
- !pth.endsWith(".png")) {
148
- continue;
149
- }
150
- const image = sharp(pth);
151
- const metadata = await image.metadata();
152
- if (metadata.width !== 128 || metadata.height !== 128) {
153
- throw new Error(`image ${pth} is not 128x128`);
154
- }
155
- }
156
- });
157
- test("relocates data", async () => {
158
- const input = `${__dirname}/data/flat_resized/data.json`;
159
- const output = `${testResultsDir}/relocated_data.json`;
160
- const relocate = new Relocate();
161
- relocate.logger.setLogLevel("error");
162
- await relocate.exec({
163
- input,
164
- output,
165
- overwrite: true,
166
- to: "newwebsite.com",
167
- from: "${repo}",
168
- });
169
- const expected = `${__dirname}/data/flat_resized/relocated_data.json`;
170
- fsEq(output, expected);
171
- });
172
- test("flattens hierarchical data", async () => {
173
- const input = `${__dirname}/data/hierarchical`;
174
- const output = `${testResultsDir}/flat`;
175
- const flatten = new Flatten();
176
- flatten.logger.setLogLevel("error");
177
- await flatten.exec({
178
- input,
179
- output,
180
- overwrite: true,
181
- });
182
- const expected = `${__dirname}/data/flat`;
183
- fsEq(output, expected);
184
- const content = fs.readFileSync(`${output}/data.json`).toString();
185
- const dataJson = JSON.parse(content.toString());
186
- const data = DataSchema.parse(dataJson);
187
- let hierCount = 0;
188
- for (const pth of fsWalk(input)) {
189
- if (!pth.endsWith(".jpg") &&
190
- !pth.endsWith(".jpeg") &&
191
- !pth.endsWith(".png")) {
192
- continue;
193
- }
194
- hierCount++;
195
- const category = pth.split("/").slice(-2)[0];
196
- const content = fs.readFileSync(pth);
197
- let name = "";
198
- for (const pth2 of fsWalk(output)) {
199
- if (!fs.statSync(pth2).isFile()) {
200
- continue;
201
- }
202
- const content2 = fs.readFileSync(pth2);
203
- if (content.equals(content2)) {
204
- const str = pth2.split("/").slice(-1)[0];
205
- if (str === undefined) {
206
- throw new Error(`unable to parse ${pth2}`);
207
- }
208
- name = str;
209
- break;
210
- }
211
- }
212
- if (!name) {
213
- throw new Error(`unable to find image ${pth} in output`);
214
- }
215
- const item = data.items.find((item) => {
216
- const name2 = item.data.split("/").slice(-1)[0];
217
- if (name2 !== name) {
218
- return false;
219
- }
220
- return true;
221
- });
222
- if (item === undefined) {
223
- throw new Error(`unable to find image ${pth} in data.json`);
224
- }
225
- if (item.label !== category) {
226
- throw new Error(`expected ${category} but found ${item.label}`);
227
- }
228
- if (item.type !== "image") {
229
- throw new Error(`expected image type but found ${item.type}`);
230
- }
231
- if (item.hash !== name.split(".")[0]) {
232
- throw new Error(`expected ${name.split(".")[0]} hash but found ${item.hash}`);
233
- }
234
- const hash = u8aToHex(blake2b(content));
235
- if (item.hash !== hash) {
236
- throw new Error(`expected ${hash} hash but found ${item.hash}`);
237
- }
238
- }
239
- let flatCount = 0;
240
- for (const pth of fsWalk(output)) {
241
- if (!pth.endsWith(".jpg") &&
242
- !pth.endsWith(".jpeg") &&
243
- !pth.endsWith(".png")) {
244
- continue;
245
- }
246
- flatCount++;
247
- }
248
- if (hierCount !== flatCount) {
249
- throw new Error(`expected ${hierCount} images but found ${flatCount}`);
250
- }
251
- });
252
- });
253
- //# sourceMappingURL=mocked.unit.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mocked.unit.test.js","sourceRoot":"","sources":["../../src/tests/mocked.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAchE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,y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I,SAAS,GAAG,CAAC,CAAC;QAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IACC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACrB,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACtB,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EACpB,CAAC;gBACF,SAAS;YACV,CAAC;YACD,SAAS,EAAE,CAAC;QACb,CAAC;QAGD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,YAAY,SAAS,qBAAqB,SAAS,EAAE,CAAC,CAAC;QACxE,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,35 +0,0 @@
1
- import { type CaptchasContainer } from "@prosopo/types";
2
- export declare function fsWalk(pth: string, options?: {
3
- filesFirst?: boolean;
4
- }): Generator<string>;
5
- export declare const fsEq: (pth1: string, pth2: string) => boolean;
6
- export declare const readDataJson: (pth: string) => {
7
- items: {
8
- hash: string;
9
- data: string;
10
- type: import("@prosopo/types").CaptchaItemTypes;
11
- label?: string | undefined;
12
- }[];
13
- };
14
- export declare const readCaptchasJson: (pth: string) => {
15
- captchas: {
16
- items: {
17
- hash: string;
18
- data: string;
19
- type: import("@prosopo/types").CaptchaItemTypes;
20
- }[];
21
- salt: string;
22
- target: string;
23
- captchaId?: string | undefined;
24
- captchaContentId?: string | undefined;
25
- solution?: number[] | undefined;
26
- unlabelled?: number[] | undefined;
27
- timeLimit?: number | undefined;
28
- }[];
29
- format: import("@prosopo/types").CaptchaTypes;
30
- };
31
- export declare const captchasEqFs: (pth1: string, pth2: string) => boolean;
32
- export declare const captchasEq: (first: CaptchasContainer, second: CaptchasContainer) => boolean;
33
- export declare const substituteRepoDir: () => void;
34
- export declare const restoreRepoDir: () => void;
35
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,gBAAgB,CAAC;AAIxB,wBAAiB,MAAM,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IACT,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,GACC,SAAS,CAAC,MAAM,CAAC,CAcnB;AAGD,eAAO,MAAM,IAAI,SAAU,MAAM,QAAQ,MAAM,YAiC9C,CAAC;AAEF,eAAO,MAAM,YAAY,QAAS,MAAM;;;;;aAyEgpb,CAAC;;CAlExrb,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM;;;;;;;;;iBAgE6kiB,CAAC;wBAA8C,CAAC;gBAAsC,CAAC;kBAA0C,CAAC;iBAAyC,CAAC;;;CA3DpyiB,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,QAAQ,MAAM,YAItD,CAAC;AAEF,eAAO,MAAM,UAAU,UACf,iBAAiB,UAChB,iBAAiB,YAoBzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAe7B,CAAC;AAEF,eAAO,MAAM,cAAc,YAS1B,CAAC"}