@nymphjs/nymph 1.0.0-beta.117 → 1.0.0-beta.119
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/CHANGELOG.md +12 -0
- package/dist/Entity.d.ts +2 -2
- package/dist/Entity.js.map +1 -1
- package/dist/Nymph.d.ts +6 -3
- package/dist/Nymph.js +3 -2
- package/dist/Nymph.js.map +1 -1
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/index.d.ts +49 -1
- package/dist/conf/index.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +6 -2
- package/dist/driver/NymphDriver.js +32 -9
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +6 -4
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.js.map +1 -1
- package/jest.config.js +25 -8
- package/package.json +17 -13
- package/src/Nymph.ts +6 -2
- package/src/conf/defaults.ts +1 -1
- package/src/conf/index.ts +49 -1
- package/src/driver/NymphDriver.ts +43 -9
- package/src/driver/testArtifacts.ts +10 -6
- package/tsconfig.json +5 -4
- package/dist/conf/d.d.ts +0 -49
- package/dist/conf/d.js +0 -2
- package/dist/conf/d.js.map +0 -1
- package/src/conf/d.ts +0 -49
- package/src/type/locutus.d.ts +0 -3
package/dist/testMocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testMocks.js","sourceRoot":"","sources":["../src/testMocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAUrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,QAAQ,GAAgC,EAAE,CAAC;AAEjD,MAAM,OAAO,eAAe;IAClB,KAAK,CAAY;IAEzB,YAAmB,KAAgB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,C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AAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SACxD,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAuB;QAC/C,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;YACnD,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/jest.config.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import { createDefaultEsmPreset } from 'ts-jest';
|
|
2
|
-
|
|
3
|
-
const presetConfig = createDefaultEsmPreset();
|
|
4
|
-
|
|
5
|
-
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
6
1
|
const jestConfig = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
|
3
|
+
testMatch: [
|
|
4
|
+
'<rootDir>/src/**/__tests__/**/*.{js,ts,jsx,tsx,mjs,mts}',
|
|
5
|
+
'<rootDir>/src/**/?(*.)(spec|test).{js,ts,jsx,tsx,mjs,mts}',
|
|
6
|
+
],
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.(ts|tsx|mts)$': [
|
|
9
|
+
'@swc/jest',
|
|
10
|
+
{
|
|
11
|
+
jsc: {
|
|
12
|
+
parser: {
|
|
13
|
+
syntax: 'typescript',
|
|
14
|
+
tsx: true,
|
|
15
|
+
decorators: true,
|
|
16
|
+
},
|
|
17
|
+
target: 'es2023',
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
type: 'commonjs',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'],
|
|
26
|
+
moduleDirectories: ['node_modules', 'src'],
|
|
10
27
|
moduleNameMapper: {
|
|
11
28
|
'^(\\.|\\.\\.)\\/(.+)\\.js': '$1/$2',
|
|
12
29
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/nymph",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.119",
|
|
4
4
|
"description": "Nymph.js - Nymph ORM",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"watch": "tsc --watch",
|
|
17
17
|
"prepublish": "npm run clean && npm run build",
|
|
18
|
-
"
|
|
19
|
-
"test
|
|
18
|
+
"typecheck": "npx tsc --noEmit",
|
|
19
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
20
|
+
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests --watch"
|
|
20
21
|
},
|
|
21
22
|
"publishConfig": {
|
|
22
23
|
"access": "public"
|
|
@@ -33,25 +34,28 @@
|
|
|
33
34
|
},
|
|
34
35
|
"license": "Apache-2.0",
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@nymphjs/guid": "^1.0.0-beta.
|
|
37
|
-
"@sciactive/tokenizer": "^3.0
|
|
37
|
+
"@nymphjs/guid": "^1.0.0-beta.119",
|
|
38
|
+
"@sciactive/tokenizer": "^3.4.0",
|
|
38
39
|
"debug": "^4.4.3",
|
|
39
|
-
"joi": "^18.
|
|
40
|
-
"locutus": "^
|
|
41
|
-
"lodash-es": "^4.
|
|
40
|
+
"joi": "^18.2.5",
|
|
41
|
+
"locutus": "^3.0.36",
|
|
42
|
+
"lodash-es": "^4.18.1",
|
|
42
43
|
"n-readlines": "^3.4.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
46
|
+
"@swc/core": "^1.16.1",
|
|
47
|
+
"@swc/jest": "^0.2.39",
|
|
45
48
|
"@tsconfig/recommended": "^1.0.13",
|
|
46
|
-
"@types/debug": "^4.1.
|
|
49
|
+
"@types/debug": "^4.1.13",
|
|
47
50
|
"@types/jest": "^30.0.0",
|
|
48
51
|
"@types/locutus": "^0.0.8",
|
|
49
52
|
"@types/lodash-es": "^4.17.12",
|
|
50
53
|
"@types/n-readlines": "^1.0.6",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
54
|
+
"@types/node": "^26.2.0",
|
|
55
|
+
"cross-env": "^10.1.0",
|
|
56
|
+
"jest": "^30.4.2",
|
|
53
57
|
"ts-node": "^10.9.2",
|
|
54
|
-
"typescript": "^
|
|
58
|
+
"typescript": "^7.0.2"
|
|
55
59
|
},
|
|
56
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "154ac28914c83b9bfe57be0797726a689c5d8ee4"
|
|
57
61
|
}
|
package/src/Nymph.ts
CHANGED
|
@@ -1126,11 +1126,15 @@ export default class Nymph {
|
|
|
1126
1126
|
* Import entities from a file.
|
|
1127
1127
|
*
|
|
1128
1128
|
* @param filename The file to import from.
|
|
1129
|
+
* @param options The options for the import.
|
|
1129
1130
|
* @returns True on success, false on failure.
|
|
1130
1131
|
*/
|
|
1131
|
-
public async import(
|
|
1132
|
+
public async import(
|
|
1133
|
+
filename: string,
|
|
1134
|
+
options?: { ignoreUnknownETypes?: boolean },
|
|
1135
|
+
): Promise<boolean> {
|
|
1132
1136
|
try {
|
|
1133
|
-
return await this.driver.import(filename);
|
|
1137
|
+
return await this.driver.import(filename, options);
|
|
1134
1138
|
} catch (e: any) {
|
|
1135
1139
|
this.config.debugError('nymph', `Failed to import: ${e}`);
|
|
1136
1140
|
throw e;
|
package/src/conf/defaults.ts
CHANGED
package/src/conf/index.ts
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Nymph Config
|
|
3
|
+
*/
|
|
4
|
+
export interface Config {
|
|
5
|
+
/**
|
|
6
|
+
* Cache recently retrieved entities to speed up database queries. Uses more
|
|
7
|
+
* memory.
|
|
8
|
+
*/
|
|
9
|
+
cache: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Cache entities after they're accessed this many times.
|
|
12
|
+
*/
|
|
13
|
+
cacheThreshold: number;
|
|
14
|
+
/**
|
|
15
|
+
* The number of recently retrieved entities to cache. If you're running out
|
|
16
|
+
* of memory, try lowering this value. 0 means unlimited.
|
|
17
|
+
*/
|
|
18
|
+
cacheLimit: number;
|
|
19
|
+
/**
|
|
20
|
+
* When querying for multiple entities with NymphREST, if the list is empty,
|
|
21
|
+
* return a 404 error.
|
|
22
|
+
*/
|
|
23
|
+
emptyListError: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to update the mdate property when saving an entity.
|
|
26
|
+
*
|
|
27
|
+
* You should probably only set this to false if you're doing migrations. Some
|
|
28
|
+
* things depend on having updated mdates (like conflict detection to avoid
|
|
29
|
+
* lost updates).
|
|
30
|
+
*
|
|
31
|
+
* If you set this to a number, that amount of milliseconds will be added to
|
|
32
|
+
* the mdate on any entities that are saved. This should solve the lost update
|
|
33
|
+
* problem when set to a small number (~1000), and keep mdates relatively
|
|
34
|
+
* unchanged.
|
|
35
|
+
*/
|
|
36
|
+
updateMDate: boolean | number;
|
|
37
|
+
/**
|
|
38
|
+
* A function to log info messages. By default, uses the `debug` package.
|
|
39
|
+
*/
|
|
40
|
+
debugInfo: (source: string, message: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* A function to log debug messages. By default, uses the `debug` package.
|
|
43
|
+
*/
|
|
44
|
+
debugLog: (source: string, message: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* A function to log error messages. By default, uses the `debug` package.
|
|
47
|
+
*/
|
|
48
|
+
debugError: (source: string, message: string) => void;
|
|
49
|
+
}
|
|
2
50
|
|
|
3
51
|
import defaults from './defaults.js';
|
|
4
52
|
export { defaults as ConfigDefaults };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { difference } from 'lodash-es';
|
|
3
3
|
import ReadLines from 'n-readlines';
|
|
4
|
-
import strtotime from 'locutus/php/datetime/
|
|
4
|
+
import { strtotime } from 'locutus/php/datetime/index';
|
|
5
5
|
import { Tokenizer } from '@sciactive/tokenizer';
|
|
6
6
|
|
|
7
7
|
import type Nymph from '../Nymph.js';
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
SerializedEntityData,
|
|
16
16
|
} from '../Entity.types.js';
|
|
17
17
|
import {
|
|
18
|
+
ClassNotAvailableError,
|
|
18
19
|
InvalidParametersError,
|
|
19
20
|
UnableToConnectError,
|
|
20
21
|
} from '../errors/index.js';
|
|
@@ -275,6 +276,7 @@ export default abstract class NymphDriver {
|
|
|
275
276
|
|
|
276
277
|
public async importDataIterator(
|
|
277
278
|
lines: Iterable<string>,
|
|
279
|
+
options?: { ignoreUnknownETypes?: boolean },
|
|
278
280
|
transaction?: boolean,
|
|
279
281
|
) {
|
|
280
282
|
const first = lines[Symbol.iterator]().next();
|
|
@@ -313,7 +315,23 @@ export default abstract class NymphDriver {
|
|
|
313
315
|
delete sdata.cdate;
|
|
314
316
|
const mdate = Number(JSON.parse(sdata.mdate));
|
|
315
317
|
delete sdata.mdate;
|
|
316
|
-
|
|
318
|
+
try {
|
|
319
|
+
await this.importEntity({
|
|
320
|
+
guid,
|
|
321
|
+
cdate,
|
|
322
|
+
mdate,
|
|
323
|
+
tags,
|
|
324
|
+
sdata,
|
|
325
|
+
etype,
|
|
326
|
+
});
|
|
327
|
+
} catch (e: any) {
|
|
328
|
+
if (
|
|
329
|
+
!(e instanceof ClassNotAvailableError) ||
|
|
330
|
+
!options?.ignoreUnknownETypes
|
|
331
|
+
) {
|
|
332
|
+
throw e;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
317
335
|
guid = null;
|
|
318
336
|
tags = [];
|
|
319
337
|
sdata = {};
|
|
@@ -338,7 +356,16 @@ export default abstract class NymphDriver {
|
|
|
338
356
|
delete sdata.cdate;
|
|
339
357
|
const mdate = Number(JSON.parse(sdata.mdate));
|
|
340
358
|
delete sdata.mdate;
|
|
341
|
-
|
|
359
|
+
try {
|
|
360
|
+
await this.importEntity({ guid, cdate, mdate, tags, sdata, etype });
|
|
361
|
+
} catch (e: any) {
|
|
362
|
+
if (
|
|
363
|
+
!(e instanceof ClassNotAvailableError) ||
|
|
364
|
+
!options?.ignoreUnknownETypes
|
|
365
|
+
) {
|
|
366
|
+
throw e;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
342
369
|
}
|
|
343
370
|
if (transaction) {
|
|
344
371
|
await this.commit('nymph-import');
|
|
@@ -351,10 +378,18 @@ export default abstract class NymphDriver {
|
|
|
351
378
|
}
|
|
352
379
|
|
|
353
380
|
public async importData(text: string, transaction?: boolean) {
|
|
354
|
-
return await this.importDataIterator(
|
|
381
|
+
return await this.importDataIterator(
|
|
382
|
+
text.split('\n'),
|
|
383
|
+
undefined,
|
|
384
|
+
transaction,
|
|
385
|
+
);
|
|
355
386
|
}
|
|
356
387
|
|
|
357
|
-
public async import(
|
|
388
|
+
public async import(
|
|
389
|
+
filename: string,
|
|
390
|
+
options?: { ignoreUnknownETypes?: boolean },
|
|
391
|
+
transaction?: boolean,
|
|
392
|
+
) {
|
|
358
393
|
let rl: ReadLines;
|
|
359
394
|
try {
|
|
360
395
|
rl = new ReadLines(filename);
|
|
@@ -371,7 +406,7 @@ export default abstract class NymphDriver {
|
|
|
371
406
|
},
|
|
372
407
|
};
|
|
373
408
|
|
|
374
|
-
return await this.importDataIterator(lines, transaction);
|
|
409
|
+
return await this.importDataIterator(lines, options, transaction);
|
|
375
410
|
}
|
|
376
411
|
|
|
377
412
|
public checkData(
|
|
@@ -1003,7 +1038,7 @@ export default abstract class NymphDriver {
|
|
|
1003
1038
|
curValue[1] == null &&
|
|
1004
1039
|
typeof curValue[2] === 'string'
|
|
1005
1040
|
) {
|
|
1006
|
-
return [curValue[0], strtotime(curValue[2]) * 1000];
|
|
1041
|
+
return [curValue[0], (strtotime(curValue[2]) || 0) * 1000];
|
|
1007
1042
|
}
|
|
1008
1043
|
return curValue;
|
|
1009
1044
|
});
|
|
@@ -1483,8 +1518,7 @@ export default abstract class NymphDriver {
|
|
|
1483
1518
|
}) => Promise<boolean>,
|
|
1484
1519
|
startTransactionCallback: (() => Promise<void>) | null = null,
|
|
1485
1520
|
commitTransactionCallback:
|
|
1486
|
-
|
|
1487
|
-
| null = null,
|
|
1521
|
+
((success: boolean) => Promise<boolean>) | null = null,
|
|
1488
1522
|
) {
|
|
1489
1523
|
const originalGuid = entity.guid;
|
|
1490
1524
|
const originalCdate = entity.cdate;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
-
import strtotime from 'locutus/php/datetime/
|
|
4
|
+
import { strtotime } from 'locutus/php/datetime/index';
|
|
5
5
|
import { guid } from '@nymphjs/guid';
|
|
6
6
|
|
|
7
7
|
import type Nymph from '../Nymph.js';
|
|
@@ -60,7 +60,7 @@ export function EntitiesTest(
|
|
|
60
60
|
|
|
61
61
|
const entityReferenceTest: TestModelClass & TestModelData = new TestModel();
|
|
62
62
|
entityReferenceTest.string = 'wrong';
|
|
63
|
-
entityReferenceTest.timestamp = strtotime('-2 days') * 1000;
|
|
63
|
+
entityReferenceTest.timestamp = (strtotime('-2 days') || 0) * 1000;
|
|
64
64
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
65
65
|
refGuid = entityReferenceTest.guid as string;
|
|
66
66
|
testEntity.reference = entityReferenceTest;
|
|
@@ -2477,7 +2477,9 @@ export function ExportImportTest(
|
|
|
2477
2477
|
expect(model.match).toEqual(matchValue);
|
|
2478
2478
|
expect(model.number).toEqual(30);
|
|
2479
2479
|
expect(model.numberString).toEqual('30');
|
|
2480
|
-
expect(model.timestamp).toBeGreaterThanOrEqual(
|
|
2480
|
+
expect(model.timestamp).toBeGreaterThanOrEqual(
|
|
2481
|
+
strtotime('-2 minutes') || 0,
|
|
2482
|
+
);
|
|
2481
2483
|
expect(model.index).toMatch(/^\d+a$/);
|
|
2482
2484
|
|
|
2483
2485
|
await model.reference?.$wake();
|
|
@@ -2561,9 +2563,11 @@ export function ExportImportTest(
|
|
|
2561
2563
|
expect(models.length).toEqual(0);
|
|
2562
2564
|
expect(bmodels.length).toEqual(0);
|
|
2563
2565
|
|
|
2564
|
-
expect(
|
|
2565
|
-
|
|
2566
|
-
|
|
2566
|
+
expect(
|
|
2567
|
+
await nymph.import(__dirname + '/testentityexport.nex', {
|
|
2568
|
+
ignoreUnknownETypes: true,
|
|
2569
|
+
}),
|
|
2570
|
+
).toEqual(true);
|
|
2567
2571
|
|
|
2568
2572
|
await checkEntityDataAndCount();
|
|
2569
2573
|
|
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"types": ["node", "jest"],
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"lib": ["es2023"],
|
|
9
|
+
"target": "es2023",
|
|
9
10
|
"noImplicitAny": true,
|
|
10
11
|
"removeComments": false,
|
|
11
12
|
"sourceMap": true,
|
package/dist/conf/d.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nymph Config
|
|
3
|
-
*/
|
|
4
|
-
export interface Config {
|
|
5
|
-
/**
|
|
6
|
-
* Cache recently retrieved entities to speed up database queries. Uses more
|
|
7
|
-
* memory.
|
|
8
|
-
*/
|
|
9
|
-
cache: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Cache entities after they're accessed this many times.
|
|
12
|
-
*/
|
|
13
|
-
cacheThreshold: number;
|
|
14
|
-
/**
|
|
15
|
-
* The number of recently retrieved entities to cache. If you're running out
|
|
16
|
-
* of memory, try lowering this value. 0 means unlimited.
|
|
17
|
-
*/
|
|
18
|
-
cacheLimit: number;
|
|
19
|
-
/**
|
|
20
|
-
* When querying for multiple entities with NymphREST, if the list is empty,
|
|
21
|
-
* return a 404 error.
|
|
22
|
-
*/
|
|
23
|
-
emptyListError: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Whether to update the mdate property when saving an entity.
|
|
26
|
-
*
|
|
27
|
-
* You should probably only set this to false if you're doing migrations. Some
|
|
28
|
-
* things depend on having updated mdates (like conflict detection to avoid
|
|
29
|
-
* lost updates).
|
|
30
|
-
*
|
|
31
|
-
* If you set this to a number, that amount of milliseconds will be added to
|
|
32
|
-
* the mdate on any entities that are saved. This should solve the lost update
|
|
33
|
-
* problem when set to a small number (~1000), and keep mdates relatively
|
|
34
|
-
* unchanged.
|
|
35
|
-
*/
|
|
36
|
-
updateMDate: boolean | number;
|
|
37
|
-
/**
|
|
38
|
-
* A function to log info messages. By default, uses the `debug` package.
|
|
39
|
-
*/
|
|
40
|
-
debugInfo: (source: string, message: string) => void;
|
|
41
|
-
/**
|
|
42
|
-
* A function to log debug messages. By default, uses the `debug` package.
|
|
43
|
-
*/
|
|
44
|
-
debugLog: (source: string, message: string) => void;
|
|
45
|
-
/**
|
|
46
|
-
* A function to log error messages. By default, uses the `debug` package.
|
|
47
|
-
*/
|
|
48
|
-
debugError: (source: string, message: string) => void;
|
|
49
|
-
}
|
package/dist/conf/d.js
DELETED
package/dist/conf/d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"d.js","sourceRoot":"","sources":["../../src/conf/d.ts"],"names":[],"mappings":""}
|
package/src/conf/d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nymph Config
|
|
3
|
-
*/
|
|
4
|
-
export interface Config {
|
|
5
|
-
/**
|
|
6
|
-
* Cache recently retrieved entities to speed up database queries. Uses more
|
|
7
|
-
* memory.
|
|
8
|
-
*/
|
|
9
|
-
cache: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Cache entities after they're accessed this many times.
|
|
12
|
-
*/
|
|
13
|
-
cacheThreshold: number;
|
|
14
|
-
/**
|
|
15
|
-
* The number of recently retrieved entities to cache. If you're running out
|
|
16
|
-
* of memory, try lowering this value. 0 means unlimited.
|
|
17
|
-
*/
|
|
18
|
-
cacheLimit: number;
|
|
19
|
-
/**
|
|
20
|
-
* When querying for multiple entities with NymphREST, if the list is empty,
|
|
21
|
-
* return a 404 error.
|
|
22
|
-
*/
|
|
23
|
-
emptyListError: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Whether to update the mdate property when saving an entity.
|
|
26
|
-
*
|
|
27
|
-
* You should probably only set this to false if you're doing migrations. Some
|
|
28
|
-
* things depend on having updated mdates (like conflict detection to avoid
|
|
29
|
-
* lost updates).
|
|
30
|
-
*
|
|
31
|
-
* If you set this to a number, that amount of milliseconds will be added to
|
|
32
|
-
* the mdate on any entities that are saved. This should solve the lost update
|
|
33
|
-
* problem when set to a small number (~1000), and keep mdates relatively
|
|
34
|
-
* unchanged.
|
|
35
|
-
*/
|
|
36
|
-
updateMDate: boolean | number;
|
|
37
|
-
/**
|
|
38
|
-
* A function to log info messages. By default, uses the `debug` package.
|
|
39
|
-
*/
|
|
40
|
-
debugInfo: (source: string, message: string) => void;
|
|
41
|
-
/**
|
|
42
|
-
* A function to log debug messages. By default, uses the `debug` package.
|
|
43
|
-
*/
|
|
44
|
-
debugLog: (source: string, message: string) => void;
|
|
45
|
-
/**
|
|
46
|
-
* A function to log error messages. By default, uses the `debug` package.
|
|
47
|
-
*/
|
|
48
|
-
debugError: (source: string, message: string) => void;
|
|
49
|
-
}
|
package/src/type/locutus.d.ts
DELETED