@travetto/model 5.0.0-rc.3 → 5.0.0-rc.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model",
3
- "version": "5.0.0-rc.3",
3
+ "version": "5.0.0-rc.5",
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.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"
29
+ "@travetto/config": "^5.0.0-rc.5",
30
+ "@travetto/di": "^5.0.0-rc.5",
31
+ "@travetto/registry": "^5.0.0-rc.5",
32
+ "@travetto/schema": "^5.0.0-rc.5"
33
33
  },
34
34
  "peerDependencies": {
35
- "@travetto/cli": "^5.0.0-rc.3",
36
- "@travetto/test": "^5.0.0-rc.3"
35
+ "@travetto/cli": "^5.0.0-rc.5",
36
+ "@travetto/test": "^5.0.0-rc.5"
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;
@@ -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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- export function Index<T>(...indices: IndexConfig<any>[]) {
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
  }
@@ -1,5 +1,4 @@
1
- import { Class } from '@travetto/runtime';
2
- import { Primitive } from '@travetto/schema';
1
+ import type { Class, Primitive } from '@travetto/runtime';
3
2
 
4
3
  import { ModelType } from '../types/model';
5
4
 
@@ -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 { ModelType, OptionalId } from '../types/model';
5
4
  import { ModelBasicSupport } from './basic';
@@ -7,7 +7,7 @@ import { ModelCandidateUtil } from './bin/candidate';
7
7
  /**
8
8
  * Exports model schemas
9
9
  */
10
- @CliCommand({ addEnv: true, addModule: true })
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({ addEnv: true, addModule: true })
10
+ @CliCommand({ with: { env: true, module: true } })
11
11
  export class ModelInstallCommand extends BaseModelCommand {
12
12
 
13
13
  getOp(): 'createModel' { return 'createModel'; }
@@ -1,9 +1,6 @@
1
1
  /** @jsxImportSource @travetto/doc */
2
- import { readFileSync } from 'node:fs';
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 = (file: string | Function): DocJSXElement[] => {
18
- if (typeof file !== 'string') {
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 contents.matchAll(/Model(Crud|Expiry|Indexed|Bulk|Stream)Support/g)) {
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
@@ -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 new Promise(r => setTimeout(r, 100));
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);