@travetto/model 5.0.0-rc.2 → 5.0.0-rc.4
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/package.json +7 -7
- package/src/internal/service/indexed.ts +1 -2
- package/src/internal/service/storage.ts +0 -1
- package/src/provider/memory.ts +1 -2
- package/src/registry/decorator.ts +2 -3
- package/src/registry/types.ts +1 -2
- package/src/service/indexed.ts +1 -2
- package/support/cli.model_export.ts +1 -1
- package/support/cli.model_install.ts +1 -1
- package/support/doc.support.tsx +4 -10
- package/support/test/crud.ts +2 -1
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.4",
|
|
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.4",
|
|
30
|
+
"@travetto/di": "^5.0.0-rc.4",
|
|
31
|
+
"@travetto/registry": "^5.0.0-rc.4",
|
|
32
|
+
"@travetto/schema": "^5.0.0-rc.4"
|
|
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.4",
|
|
36
|
+
"@travetto/test": "^5.0.0-rc.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Class } from '@travetto/runtime';
|
|
2
|
-
import { DeepPartial } from '@travetto/schema';
|
|
1
|
+
import { Class, DeepPartial } from '@travetto/runtime';
|
|
3
2
|
|
|
4
3
|
import { IndexNotSupported } from '../../error/invalid-index';
|
|
5
4
|
import { NotFoundError } from '../../error/not-found';
|
|
@@ -20,7 +20,6 @@ export class ModelStorageUtil {
|
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
21
21
|
target = target ?? storage.constructor as Class<ModelStorageSupport>;
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
const checkType = (cls: Class, enforceBase = true): boolean => {
|
|
25
24
|
if (enforceBase && ModelRegistry.getBaseModel(cls) !== cls) {
|
|
26
25
|
return false;
|
package/src/provider/memory.ts
CHANGED
|
@@ -1,8 +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/runtime';
|
|
5
|
-
import { DeepPartial } from '@travetto/schema';
|
|
4
|
+
import { Class, TimeSpan, DeepPartial } from '@travetto/runtime';
|
|
6
5
|
import { Injectable } from '@travetto/di';
|
|
7
6
|
import { Config } from '@travetto/config';
|
|
8
7
|
|
|
@@ -24,9 +24,8 @@ export function Model(conf: Partial<ModelOptions<ModelType>> | string = {}) {
|
|
|
24
24
|
/**
|
|
25
25
|
* Defines an index on a model
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return function (target: Class<T>): void {
|
|
27
|
+
export function Index<T extends ModelType>(...indices: IndexConfig<T>[]) {
|
|
28
|
+
return function (target: Class<T>) {
|
|
30
29
|
ModelRegistry.getOrCreatePending(target).indices!.push(...indices);
|
|
31
30
|
};
|
|
32
31
|
}
|
package/src/registry/types.ts
CHANGED
package/src/service/indexed.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ModelCandidateUtil } from './bin/candidate';
|
|
|
7
7
|
/**
|
|
8
8
|
* Exports model schemas
|
|
9
9
|
*/
|
|
10
|
-
@CliCommand({
|
|
10
|
+
@CliCommand({ with: { env: true, module: true } })
|
|
11
11
|
export class ModelExportCommand extends BaseModelCommand {
|
|
12
12
|
|
|
13
13
|
getOp(): 'exportModel' { return 'exportModel'; }
|
|
@@ -7,7 +7,7 @@ import { ModelCandidateUtil } from './bin/candidate';
|
|
|
7
7
|
/**
|
|
8
8
|
* Installing models
|
|
9
9
|
*/
|
|
10
|
-
@CliCommand({
|
|
10
|
+
@CliCommand({ with: { env: true, module: true } })
|
|
11
11
|
export class ModelInstallCommand extends BaseModelCommand {
|
|
12
12
|
|
|
13
13
|
getOp(): 'createModel' { return 'createModel'; }
|
package/support/doc.support.tsx
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @travetto/doc */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { d, c, DocJSXElementByFn, DocJSXElement } from '@travetto/doc';
|
|
2
|
+
import { d, c, DocJSXElementByFn, DocJSXElement, DocFileUtil } from '@travetto/doc';
|
|
5
3
|
import { Config } from '@travetto/config';
|
|
6
|
-
import { Runtime } from '@travetto/runtime';
|
|
7
4
|
|
|
8
5
|
export const Links = {
|
|
9
6
|
Basic: d.codeLink('Basic', '@travetto/model/src/service/basic.ts', /export interface/),
|
|
@@ -14,14 +11,11 @@ export const Links = {
|
|
|
14
11
|
Stream: d.codeLink('Streaming', '@travetto/model/src/service/stream.ts', /export interface/),
|
|
15
12
|
};
|
|
16
13
|
|
|
17
|
-
export const ModelTypes = (
|
|
18
|
-
|
|
19
|
-
file = Runtime.getSource(file);
|
|
20
|
-
}
|
|
21
|
-
const contents = readFileSync(file, 'utf8');
|
|
14
|
+
export const ModelTypes = (fn: | Function): DocJSXElement[] => {
|
|
15
|
+
const { content } = DocFileUtil.readSource(fn);
|
|
22
16
|
const found: DocJSXElementByFn<'CodeLink'>[] = [];
|
|
23
17
|
const seen = new Set();
|
|
24
|
-
for (const [, key] of
|
|
18
|
+
for (const [, key] of content.matchAll(/Model(Crud|Expiry|Indexed|Bulk|Stream)Support/g)) {
|
|
25
19
|
if (!seen.has(key)) {
|
|
26
20
|
seen.add(key);
|
|
27
21
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
package/support/test/crud.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
|
+
import timers from 'node:timers/promises';
|
|
2
3
|
|
|
3
4
|
import { Suite, Test } from '@travetto/test';
|
|
4
5
|
import { Schema, Text, Precision, Required, } from '@travetto/schema';
|
|
@@ -224,7 +225,7 @@ export abstract class ModelCrudSuite extends BaseModelSuite<ModelCrudSupport> {
|
|
|
224
225
|
assert(res.createdDate instanceof Date);
|
|
225
226
|
assert(res.updatedDate instanceof Date);
|
|
226
227
|
|
|
227
|
-
await
|
|
228
|
+
await timers.setTimeout(100);
|
|
228
229
|
|
|
229
230
|
const final = await service.updatePartial(Dated, { id: res.id });
|
|
230
231
|
assert(final.createdDate instanceof Date);
|