@travetto/model 5.0.0-rc.1 → 5.0.0-rc.3
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/README.md +1 -1
- package/package.json +7 -7
- package/src/error/exists.ts +1 -1
- package/src/error/invalid-index.ts +1 -1
- package/src/error/invalid-sub-type.ts +1 -1
- package/src/error/not-found.ts +1 -1
- package/src/internal/service/bulk.ts +1 -1
- package/src/internal/service/crud.ts +1 -1
- package/src/internal/service/expiry.ts +1 -1
- package/src/internal/service/indexed.ts +1 -1
- package/src/internal/service/storage.ts +2 -2
- package/src/internal/service/stream.ts +1 -1
- package/src/provider/file.ts +2 -2
- package/src/provider/memory.ts +1 -1
- package/src/registry/decorator.ts +1 -1
- package/src/registry/model.ts +9 -3
- package/src/registry/types.ts +1 -1
- package/src/service/basic.ts +1 -1
- package/src/service/bulk.ts +1 -1
- package/src/service/crud.ts +1 -1
- package/src/service/expiry.ts +1 -1
- package/src/service/indexed.ts +1 -1
- package/src/service/storage.ts +1 -1
- package/support/base-command.ts +1 -1
- package/support/bin/candidate.ts +1 -1
- package/support/bin/export.ts +1 -1
- package/support/bin/install.ts +1 -1
- package/support/doc.support.tsx +2 -2
- package/support/test/base.ts +1 -1
- package/support/test/expiry.ts +1 -1
- package/support/test/indexed.ts +1 -1
- package/support/test/suite.ts +1 -1
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ In addition to the provided contracts, the module also provides common utilities
|
|
|
235
235
|
```typescript
|
|
236
236
|
import { Readable } from 'node:stream';
|
|
237
237
|
import { buffer as toBuffer } from 'node:stream/consumers';
|
|
238
|
-
import { Class, TimeSpan } from '@travetto/
|
|
238
|
+
import { Class, TimeSpan } from '@travetto/runtime';
|
|
239
239
|
import { DeepPartial } from '@travetto/schema';
|
|
240
240
|
import { Injectable } from '@travetto/di';
|
|
241
241
|
import { Config } from '@travetto/config';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.3",
|
|
4
4
|
"description": "Datastore abstraction for core operations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "module/model"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^5.0.0-rc.
|
|
30
|
-
"@travetto/di": "^5.0.0-rc.
|
|
31
|
-
"@travetto/registry": "^5.0.0-rc.
|
|
32
|
-
"@travetto/schema": "^5.0.0-rc.
|
|
29
|
+
"@travetto/config": "^5.0.0-rc.3",
|
|
30
|
+
"@travetto/di": "^5.0.0-rc.3",
|
|
31
|
+
"@travetto/registry": "^5.0.0-rc.3",
|
|
32
|
+
"@travetto/schema": "^5.0.0-rc.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
36
|
-
"@travetto/test": "^5.0.0-rc.
|
|
35
|
+
"@travetto/cli": "^5.0.0-rc.3",
|
|
36
|
+
"@travetto/test": "^5.0.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/src/error/exists.ts
CHANGED
package/src/error/not-found.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
|
|
3
|
-
import { Class, Util } from '@travetto/
|
|
3
|
+
import { Class, Util } from '@travetto/runtime';
|
|
4
4
|
import { DataUtil, SchemaRegistry, SchemaValidator, ValidationError, ValidationResultError } from '@travetto/schema';
|
|
5
5
|
|
|
6
6
|
import { ModelRegistry } from '../../registry/model';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShutdownManager, Class, TimeSpan, TimeUtil, Util } from '@travetto/
|
|
1
|
+
import { ShutdownManager, Class, TimeSpan, TimeUtil, Util } from '@travetto/runtime';
|
|
2
2
|
|
|
3
3
|
import { ModelRegistry } from '../../registry/model';
|
|
4
4
|
import { ModelExpirySupport } from '../../service/expiry';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Class,
|
|
1
|
+
import { Class, Runtime } from '@travetto/runtime';
|
|
2
2
|
import { SchemaChangeListener } from '@travetto/schema';
|
|
3
3
|
|
|
4
4
|
import { ModelRegistry } from '../../registry/model';
|
|
@@ -13,7 +13,7 @@ export class ModelStorageUtil {
|
|
|
13
13
|
* Register change listener on startup
|
|
14
14
|
*/
|
|
15
15
|
static async registerModelChangeListener(storage: ModelStorageSupport, target?: Class): Promise<void> {
|
|
16
|
-
if (!
|
|
16
|
+
if (!Runtime.dynamic || !(storage?.config?.autoCreate ?? !Runtime.production)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
|
package/src/provider/file.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Readable } from 'node:stream';
|
|
|
5
5
|
import { pipeline } from 'node:stream/promises';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
|
-
import { Class, TimeSpan,
|
|
8
|
+
import { Class, TimeSpan, Runtime } from '@travetto/runtime';
|
|
9
9
|
import { Injectable } from '@travetto/di';
|
|
10
10
|
import { Config } from '@travetto/config';
|
|
11
11
|
import { Required } from '@travetto/schema';
|
|
@@ -36,7 +36,7 @@ export class FileModelConfig {
|
|
|
36
36
|
cullRate?: number | TimeSpan;
|
|
37
37
|
|
|
38
38
|
async postConstruct(): Promise<void> {
|
|
39
|
-
this.folder ??= path.resolve(os.tmpdir(), `trv_file_${
|
|
39
|
+
this.folder ??= path.resolve(os.tmpdir(), `trv_file_${Runtime.main.name.replace(/[^a-z]/ig, '_')}`);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
package/src/provider/memory.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { buffer as toBuffer } from 'node:stream/consumers';
|
|
3
3
|
|
|
4
|
-
import { Class, TimeSpan } from '@travetto/
|
|
4
|
+
import { Class, TimeSpan } from '@travetto/runtime';
|
|
5
5
|
import { DeepPartial } from '@travetto/schema';
|
|
6
6
|
import { Injectable } from '@travetto/di';
|
|
7
7
|
import { Config } from '@travetto/config';
|
package/src/registry/model.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
2
1
|
import { SchemaRegistry } from '@travetto/schema';
|
|
3
2
|
import { MetadataRegistry } from '@travetto/registry';
|
|
4
3
|
import { DependencyRegistry } from '@travetto/di';
|
|
5
|
-
import { AppError, Class } from '@travetto/
|
|
4
|
+
import { AppError, Class, describeFunction } from '@travetto/runtime';
|
|
6
5
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
7
6
|
|
|
8
7
|
import { IndexConfig, IndexType, ModelOptions } from './types';
|
|
@@ -52,7 +51,14 @@ class $ModelRegistry extends MetadataRegistry<ModelOptions<ModelType>> {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
createPending(cls: Class): Partial<ModelOptions<ModelType>> {
|
|
55
|
-
return {
|
|
54
|
+
return {
|
|
55
|
+
class: cls,
|
|
56
|
+
indices: [],
|
|
57
|
+
autoCreate: true,
|
|
58
|
+
baseType: describeFunction(cls).abstract,
|
|
59
|
+
postLoad: [],
|
|
60
|
+
prePersist: []
|
|
61
|
+
};
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
registerDataHandlers(cls: Class, pConfig?: Partial<ModelOptions<ModelType>>): void {
|
package/src/registry/types.ts
CHANGED
package/src/service/basic.ts
CHANGED
package/src/service/bulk.ts
CHANGED
package/src/service/crud.ts
CHANGED
package/src/service/expiry.ts
CHANGED
package/src/service/indexed.ts
CHANGED
package/src/service/storage.ts
CHANGED
package/support/base-command.ts
CHANGED
package/support/bin/candidate.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Class } from '@travetto/
|
|
1
|
+
import { Class } from '@travetto/runtime';
|
|
2
2
|
import { ModelRegistry } from '@travetto/model/src/registry/model';
|
|
3
3
|
import { InjectableConfig, DependencyRegistry } from '@travetto/di';
|
|
4
4
|
import { ModelStorageSupportTarget } from '@travetto/model/src/internal/service/common';
|
package/support/bin/export.ts
CHANGED
package/support/bin/install.ts
CHANGED
package/support/doc.support.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource @travetto/doc */
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
|
|
4
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
5
4
|
import { d, c, DocJSXElementByFn, DocJSXElement } from '@travetto/doc';
|
|
6
5
|
import { Config } from '@travetto/config';
|
|
6
|
+
import { Runtime } from '@travetto/runtime';
|
|
7
7
|
|
|
8
8
|
export const Links = {
|
|
9
9
|
Basic: d.codeLink('Basic', '@travetto/model/src/service/basic.ts', /export interface/),
|
|
@@ -16,7 +16,7 @@ export const Links = {
|
|
|
16
16
|
|
|
17
17
|
export const ModelTypes = (file: string | Function): DocJSXElement[] => {
|
|
18
18
|
if (typeof file !== 'string') {
|
|
19
|
-
file =
|
|
19
|
+
file = Runtime.getSource(file);
|
|
20
20
|
}
|
|
21
21
|
const contents = readFileSync(file, 'utf8');
|
|
22
22
|
const found: DocJSXElementByFn<'CodeLink'>[] = [];
|
package/support/test/base.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DependencyRegistry } from '@travetto/di';
|
|
2
|
-
import { AppError, Class } from '@travetto/
|
|
2
|
+
import { AppError, Class } from '@travetto/runtime';
|
|
3
3
|
|
|
4
4
|
import { isBulkSupported, isCrudSupported } from '../../src/internal/service/common';
|
|
5
5
|
import { ModelType } from '../../src/types/model';
|
package/support/test/expiry.ts
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import timers from 'node:timers/promises';
|
|
3
3
|
|
|
4
4
|
import { Suite, Test } from '@travetto/test';
|
|
5
|
-
import { TimeSpan, TimeUnit, TimeUtil } from '@travetto/
|
|
5
|
+
import { TimeSpan, TimeUnit, TimeUtil } from '@travetto/runtime';
|
|
6
6
|
|
|
7
7
|
import { ExpiresAt, Model } from '../../src/registry/decorator';
|
|
8
8
|
import { ModelExpirySupport } from '../../src/service/expiry';
|
package/support/test/indexed.ts
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
|
|
3
3
|
import { Suite, Test } from '@travetto/test';
|
|
4
4
|
import { Schema } from '@travetto/schema';
|
|
5
|
-
import { TimeUtil } from '@travetto/
|
|
5
|
+
import { TimeUtil } from '@travetto/runtime';
|
|
6
6
|
|
|
7
7
|
import { Index, Model } from '../../src/registry/decorator';
|
|
8
8
|
import { ModelIndexedSupport } from '../../src/service/indexed';
|
package/support/test/suite.ts
CHANGED