@loomcore/common 0.0.34 → 0.0.35

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.
@@ -1,7 +1,9 @@
1
- import { TSchema, TString, TNumber } from '@sinclair/typebox';
2
- export interface IEntity<TId extends string | number = string> {
3
- _id: TId;
4
- _orgId?: TId;
1
+ import { AppId } from '../types/app.types.js';
2
+ export interface IEntity {
3
+ _id: AppId;
4
+ _orgId?: AppId;
5
5
  }
6
- export declare let EntitySchema: TSchema;
7
- export declare const createEntitySchema: (idType: TString | TNumber) => TSchema;
6
+ export declare const EntitySchema: import("@sinclair/typebox").TObject<{
7
+ _id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
8
+ _orgId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnsafe<unknown>>;
9
+ }>;
@@ -1,12 +1,6 @@
1
1
  import { Type } from '@sinclair/typebox';
2
- export let EntitySchema;
3
- export const createEntitySchema = (idType) => {
4
- const orgIdType = idType.kind === 'String'
5
- ? Type.String({ ...idType, title: 'Organization ID' })
6
- : Type.Number({ ...idType, title: 'Organization ID' });
7
- EntitySchema = Type.Object({
8
- _id: idType,
9
- _orgId: Type.Optional(orgIdType)
10
- });
11
- return EntitySchema;
12
- };
2
+ import { IdSchema } from '../validation/id-schema.provider.js';
3
+ export const EntitySchema = Type.Object({
4
+ _id: IdSchema,
5
+ _orgId: Type.Optional(Type.Unsafe({ ...IdSchema, title: 'Organization ID' }))
6
+ });
@@ -0,0 +1,4 @@
1
+ export interface AppIdType {
2
+ id: string | number;
3
+ }
4
+ export type AppId = AppIdType['id'];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const IdSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
@@ -0,0 +1,5 @@
1
+ import { Type } from '@sinclair/typebox';
2
+ export const IdSchema = Type.Union([
3
+ Type.String({ title: 'ID' }),
4
+ Type.Number({ title: 'ID' })
5
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/common",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "private": false,
5
5
  "description": "Loom Core Models- common models, interfaces, types, and utils for Loom Core. All things common to both api and client apps.",
6
6
  "scripts": {