@declaro/data 2.0.0-beta.47 → 2.0.0-beta.48

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.
@@ -12,5 +12,6 @@ export * from './domain/services/model-service';
12
12
  export * from './domain/services/model-service-args';
13
13
  export * from './domain/services/read-only-model-service';
14
14
  export * from './shared/utils/schema-inference';
15
+ export * from './shared/utils/schema-inheritance';
15
16
  export * from './test/mock/models/mock-book-models';
16
17
  export * from './test/mock/repositories/mock-memory-repository';
@@ -0,0 +1,22 @@
1
+ import type { Model, ModelSchema } from '@declaro/core';
2
+ /**
3
+ * Represents a child schema that inherits from a parent schema.
4
+ * This is useful for creating schemas that extend the functionality of an existing schema.
5
+ * It replaces the schema name and all model names with a string type.
6
+ *
7
+ * @warning This type is intended for use in generic types. In most cases, you should use concrete schemas for inheritance for best type inference.
8
+ *
9
+ * @template TSchema - The parent schema type.
10
+ * @example
11
+ * ```ts
12
+ * import { ModelSchema, ChildSchema } from '@declaro/core';
13
+ *
14
+ * export class ParentService<TSchema extends ChildSchema<typeof ParentSchema>> extends ModelService<TSchema> {
15
+ * constructor(args: IModelServiceArgs<TSchema>) {
16
+ * super(args);
17
+ * }
18
+ * }
19
+ */
20
+ export type ChildSchema<TSchema extends ModelSchema> = ModelSchema<string, {
21
+ [K in keyof TSchema['definition']]: Model<string, TSchema['definition'][K]['schema']>;
22
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declaro/data",
3
- "version": "2.0.0-beta.47",
3
+ "version": "2.0.0-beta.48",
4
4
  "description": "A data-mapper framework for managing application data across integrated systems.",
5
5
  "main": "dist/node/index.cjs",
6
6
  "module": "dist/browser/index.js",
@@ -19,8 +19,8 @@
19
19
  "@declaro/core": "^2.0.0-beta.46"
20
20
  },
21
21
  "devDependencies": {
22
- "@declaro/auth": "^2.0.0-beta.47",
23
- "@declaro/core": "^2.0.0-beta.47",
22
+ "@declaro/auth": "^2.0.0-beta.48",
23
+ "@declaro/core": "^2.0.0-beta.48",
24
24
  "typescript": "^5.8.3",
25
25
  "uuid": "^11.1.0",
26
26
  "zod": "^3.25.67"
@@ -40,5 +40,5 @@
40
40
  },
41
41
  "require": "./dist/node/index.cjs"
42
42
  },
43
- "gitHead": "8d97883a815d4702ad8dac2a86835bbb6f345b6c"
43
+ "gitHead": "a07a4c3c87ea512be16aca5a9f89d42a0b539fc5"
44
44
  }
package/src/index.ts CHANGED
@@ -12,5 +12,6 @@ export * from './domain/services/model-service'
12
12
  export * from './domain/services/model-service-args'
13
13
  export * from './domain/services/read-only-model-service'
14
14
  export * from './shared/utils/schema-inference'
15
+ export * from './shared/utils/schema-inheritance'
15
16
  export * from './test/mock/models/mock-book-models'
16
17
  export * from './test/mock/repositories/mock-memory-repository'
@@ -0,0 +1,26 @@
1
+ import type { Model, ModelSchema } from '@declaro/core'
2
+
3
+ /**
4
+ * Represents a child schema that inherits from a parent schema.
5
+ * This is useful for creating schemas that extend the functionality of an existing schema.
6
+ * It replaces the schema name and all model names with a string type.
7
+ *
8
+ * @warning This type is intended for use in generic types. In most cases, you should use concrete schemas for inheritance for best type inference.
9
+ *
10
+ * @template TSchema - The parent schema type.
11
+ * @example
12
+ * ```ts
13
+ * import { ModelSchema, ChildSchema } from '@declaro/core';
14
+ *
15
+ * export class ParentService<TSchema extends ChildSchema<typeof ParentSchema>> extends ModelService<TSchema> {
16
+ * constructor(args: IModelServiceArgs<TSchema>) {
17
+ * super(args);
18
+ * }
19
+ * }
20
+ */
21
+ export type ChildSchema<TSchema extends ModelSchema> = ModelSchema<
22
+ string,
23
+ {
24
+ [K in keyof TSchema['definition']]: Model<string, TSchema['definition'][K]['schema']>
25
+ }
26
+ >