teamplay 0.5.0-alpha.3 → 0.5.0-alpha.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/dist/index.d.ts +21 -4
- package/dist/orm/Aggregation.d.ts +1 -1
- package/dist/orm/Aggregation.js +6 -2
- package/dist/orm/Signal.d.ts +2 -2
- package/dist/orm/SignalBase.d.ts +2 -2
- package/dist/orm/SignalBase.js +4 -1
- package/dist/orm/addModel.d.ts +9 -2
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/signalMetadata.d.ts +1 -1
- package/dist/orm/signalMetadata.js +28 -2
- package/dist/orm/signalReads.d.ts +1 -1
- package/dist/orm/signalReads.js +10 -4
- package/dist/orm/types/baseMethods.d.ts +1 -1
- package/dist/orm/types/modelManifest.d.ts +12 -1
- package/dist/orm/types/signal.d.ts +44 -15
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import { SEGMENTS } from './orm/Signal.js';
|
|
3
3
|
import useApi from './react/useApi.js';
|
|
4
|
-
import type { AnySignal, ArraySignal, CollectionDocument, CollectionDocumentModel, CollectionSignal, CollectionSignalFromSpec, CollectionAggregationSignal, CollectionQuerySignal, CollectionSpec, CollectionsFromManifest, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, ModelEntry, ModelManifest, PathModelsFromManifest, PublicSignal, LocalSignalFactory, RuntimeSignalConstructor, RuntimeSignalInstance, RootCollections, RootSignal, WildcardPathSegment, WildcardSignalPath, AppendPath, ComputedQueryParamsInput, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, SignalChild, SignalBaseInstance, SignalArrayMutatorMethods, SignalArrayReaderMethods, SignalClass, SignalCollectionMethods, SignalConstructor, SignalForKind, SignalKind, SignalMetadataMethods, SignalModelConstructor, SignalStringMutatorMethods, SignalValueMethods, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec } from './orm/Signal.js';
|
|
4
|
+
import type { AnySignal, ArraySignal, CollectionDocument, CollectionDocumentModel, CollectionSignal, CollectionSignalFromSpec, CollectionAggregationSignal, CollectionQuerySignal, CollectionSpec, CollectionsFromManifest, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, ModelEntry, ModelManifest, PathModelsFromManifest, PrivateCollectionsFromManifest, PrivateSignalFromSpec, PublicSignal, LocalSignalFactory, RuntimeSignalConstructor, RuntimeSignalInstance, RootCollections, RootPrivateCollections, RootSignal, WildcardPathSegment, WildcardSignalPath, AppendPath, ComputedQueryParamsInput, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, SignalChild, SignalBaseInstance, SignalArrayMutatorMethods, SignalArrayReaderMethods, SignalClass, SignalCollectionMethods, SignalConstructor, SignalForKind, SignalKind, SignalMetadataMethods, SignalModelConstructor, SignalStringMutatorMethods, SignalValueMethods, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec } from './orm/Signal.js';
|
|
5
5
|
export interface TeamplayCollections {
|
|
6
6
|
}
|
|
7
|
+
export interface TeamplayPrivateCollections {
|
|
8
|
+
}
|
|
7
9
|
export interface TeamplayModels {
|
|
8
10
|
}
|
|
9
11
|
export interface TeamplaySignalFields {
|
|
10
12
|
}
|
|
13
|
+
export interface TeamplayPluginCollections {
|
|
14
|
+
}
|
|
15
|
+
export interface TeamplayPluginPrivateCollections {
|
|
16
|
+
}
|
|
17
|
+
export interface TeamplayPluginModels {
|
|
18
|
+
}
|
|
19
|
+
export interface TeamplayPluginSignalFields {
|
|
20
|
+
}
|
|
21
|
+
export interface TeamplayPluginOptions {
|
|
22
|
+
}
|
|
23
|
+
export interface TeamplayFeatures {
|
|
24
|
+
}
|
|
25
|
+
export type TeamplayPluginOption<TName extends string> = TName extends keyof TeamplayPluginOptions ? TeamplayPluginOptions[TName] : {};
|
|
26
|
+
export type TeamplayFeature<TName extends string> = TName extends keyof TeamplayFeatures ? TeamplayFeatures[TName] : unknown;
|
|
11
27
|
export type Signal<TValue = unknown> = PublicSignal<TValue>;
|
|
12
|
-
export type { AnySignal, ArraySignal, CollectionDocument, CollectionDocumentModel, CollectionSignal, CollectionSpec, CollectionSignalFromSpec, CollectionAggregationSignal, CollectionQuerySignal, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, ModelEntry, ModelManifest, CollectionsFromManifest, LocalSignalFactory, PathModelsFromManifest, PublicSignal, RuntimeSignalConstructor, RuntimeSignalInstance, RootCollections, RootSignal, WildcardPathSegment, WildcardSignalPath, AppendPath, ComputedQueryParamsInput, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, SignalArrayMutatorMethods, SignalArrayReaderMethods, SignalBaseInstance, SignalClass, SignalChild, SignalConstructor, SignalCollectionMethods, SignalForKind, SignalKind, SignalMetadataMethods, SignalModelConstructor, SignalStringMutatorMethods, SignalValueMethods, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec };
|
|
28
|
+
export type { AnySignal, ArraySignal, CollectionDocument, CollectionDocumentModel, CollectionSignal, CollectionSpec, CollectionSignalFromSpec, CollectionAggregationSignal, CollectionQuerySignal, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, ModelEntry, ModelManifest, CollectionsFromManifest, PrivateCollectionsFromManifest, LocalSignalFactory, PathModelsFromManifest, PrivateSignalFromSpec, PublicSignal, RuntimeSignalConstructor, RuntimeSignalInstance, RootCollections, RootSignal, WildcardPathSegment, WildcardSignalPath, AppendPath, ComputedQueryParamsInput, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, RootPrivateCollections, SignalArrayMutatorMethods, SignalArrayReaderMethods, SignalBaseInstance, SignalClass, SignalChild, SignalConstructor, SignalCollectionMethods, SignalForKind, SignalKind, SignalMetadataMethods, SignalModelConstructor, SignalStringMutatorMethods, SignalValueMethods, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec };
|
|
13
29
|
export interface ObserverOptions {
|
|
14
30
|
forwardRef?: boolean;
|
|
15
31
|
cache?: boolean;
|
|
@@ -54,7 +70,7 @@ export { GUID_PATTERN, defineSchema, hasMany, hasOne, hasManyFlags, belongsTo, p
|
|
|
54
70
|
export { aggregation, aggregationHeader as __aggregationHeader } from '@teamplay/utils/aggregation';
|
|
55
71
|
export { accessControl } from '@teamplay/utils/accessControl';
|
|
56
72
|
export type { AggregationCallback, AggregationContext, AggregationFunction, AggregationMeta, AggregationParams, AggregationQuery, ClientAggregationFunction, DefaultAggregationSession } from '@teamplay/utils/aggregation';
|
|
57
|
-
export type { AccessControl, AccessControlRules, AccessCreateContext, AccessDecision, AccessDeleteContext, AccessOperation, AccessReadContext, AccessRule, AccessUpdateContext, AccessValidator, AccessValidatorObject, DefaultAccessSession } from '@teamplay/utils/accessControl';
|
|
73
|
+
export type { AccessControl, AccessControlOptions, AccessControlRules, AccessCreateContext, AccessDecision, AccessDeleteContext, AccessOperation, AccessReadContext, AccessRule, AccessUpdateContext, AccessValidator, AccessValidatorObject, DefaultAccessSession } from '@teamplay/utils/accessControl';
|
|
58
74
|
export declare function batch(): undefined;
|
|
59
75
|
export declare function batch<TResult>(fn: () => TResult): TResult;
|
|
60
76
|
export declare function batchModel(): undefined;
|
|
@@ -63,4 +79,5 @@ export declare function serverOnly<TValue>(value: TValue): TValue;
|
|
|
63
79
|
export declare function clone<TValue>(value: TValue): TValue;
|
|
64
80
|
export declare function initLocalCollection(name: string): any;
|
|
65
81
|
export { useApi };
|
|
66
|
-
export declare function getRootSignal
|
|
82
|
+
export declare function getRootSignal(options?: Record<string, any>): RootSignal;
|
|
83
|
+
export declare function getRootSignal<TCollections extends Record<string, any>>(options?: Record<string, any>): RootSignal<TCollections>;
|
|
@@ -13,5 +13,5 @@ export function getAggregationDocId (
|
|
|
13
13
|
segments: readonly unknown[],
|
|
14
14
|
rootId?: string,
|
|
15
15
|
method?: (path: unknown[]) => unknown
|
|
16
|
-
): string |
|
|
16
|
+
): string | undefined
|
|
17
17
|
export function getAggregationCollectionName (segments: readonly unknown[]): string | undefined
|
package/dist/orm/Aggregation.js
CHANGED
|
@@ -91,8 +91,12 @@ export function getAggregationDocId(segments, rootId, method) {
|
|
|
91
91
|
if (typeof method !== 'function') {
|
|
92
92
|
method = path => rootId == null ? getRaw(path) : getPrivateData(rootId, path);
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
94
|
+
const underscoreId = method([...segments.slice(0, 3), '_id']);
|
|
95
|
+
if (typeof underscoreId === 'string')
|
|
96
|
+
return underscoreId;
|
|
97
|
+
const id = method([...segments.slice(0, 3), 'id']);
|
|
98
|
+
if (typeof id === 'string')
|
|
99
|
+
return id;
|
|
96
100
|
}
|
|
97
101
|
export function getAggregationCollectionName(segments) {
|
|
98
102
|
if (!(segments.length >= 2))
|
package/dist/orm/Signal.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export type { FromJsonSchema, InferZodSchema, JsonSchema, JsonSchemaObject, ZodL
|
|
|
4
4
|
export type { ComputedQueryParamsInput, QueryParams, QueryParamsInput } from './types/query.js';
|
|
5
5
|
export type { SignalArrayMutatorMethods, SignalArrayReaderMethods, SignalCollectionMethods, SignalMetadataMethods, SignalStringMutatorMethods, SignalValueMethods } from './types/baseMethods.js';
|
|
6
6
|
export type { AppendPath, JoinPath, PathSegment, SignalPath, WildcardPathSegment, WildcardSignalPath } from './types/path.js';
|
|
7
|
-
export type { AggregationSignal, AnySignal, ArraySignal, CollectionAggregationSignal, CollectionDocument, CollectionDocumentModel, CollectionQuerySignal, CollectionSignal, CollectionSignalFromSpec, CollectionSpec, DocumentSignal, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, PublicSignal, LocalSignalFactory, RegisteredAggregationInput, RuntimeSignalConstructor, RuntimeSignalInstance, QuerySignal, RootCollections, RootSignal, SignalBaseInstance, SignalChild, SignalChildren, SignalClass, SignalConstructor, SignalForKind, SignalKind, SignalInstance, SignalModelConstructor, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodSchemaSpec } from './types/signal.js';
|
|
8
|
-
export type { CollectionsFromManifest, ModelEntry, ModelManifest, PathModelsFromManifest } from './types/modelManifest.js';
|
|
7
|
+
export type { AggregationSignal, AnySignal, ArraySignal, CollectionAggregationSignal, CollectionDocument, CollectionDocumentModel, CollectionQuerySignal, CollectionSignal, CollectionSignalFromSpec, CollectionSpec, DocumentSignal, JsonSchemaSpec, MaybePromise, MaybePromiseSubResult, PublicSignal, LocalSignalFactory, RegisteredAggregationInput, RuntimeSignalConstructor, RuntimeSignalInstance, QuerySignal, RootCollections, RootSignal, SignalBaseInstance, SignalChild, SignalChildren, SignalClass, SignalConstructor, SignalForKind, SignalKind, SignalInstance, SignalModelConstructor, PrivateSignalFromSpec, RootPrivateCollections, SubResult, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodSchemaSpec } from './types/signal.js';
|
|
8
|
+
export type { CollectionsFromManifest, ModelEntry, ModelManifest, PathModelsFromManifest, PrivateCollectionsFromManifest } from './types/modelManifest.js';
|
|
9
9
|
export { Signal, SEGMENTS, ARRAY_METHOD, GET, GETTERS, DEFAULT_GETTERS, regularBindings, extremelyLateBindings, isPublicCollectionSignal, isPublicDocumentSignal, isPublicCollection, isPrivateCollection } from './SignalBase.js';
|
|
10
10
|
export { SignalCompat };
|
|
11
11
|
declare const DefaultSignal: SignalConstructor;
|
package/dist/orm/SignalBase.d.ts
CHANGED
|
@@ -51,11 +51,11 @@ export declare class Signal<TValue = unknown> extends Function {
|
|
|
51
51
|
/** Read the current value and track it for reactive rendering. */
|
|
52
52
|
get(): TValue;
|
|
53
53
|
/** Return document ids for a query or aggregation signal. */
|
|
54
|
-
getIds():
|
|
54
|
+
getIds(): string[];
|
|
55
55
|
/** Read the current value without tracking it for reactive rendering. */
|
|
56
56
|
peek(): TValue;
|
|
57
57
|
/** Return the document id represented by this document signal. */
|
|
58
|
-
getId(): string |
|
|
58
|
+
getId(): string | undefined;
|
|
59
59
|
/** Return the public collection name this signal belongs to. */
|
|
60
60
|
getCollection(): string;
|
|
61
61
|
/** Return association metadata registered on this signal's model class. */
|
package/dist/orm/SignalBase.js
CHANGED
|
@@ -205,7 +205,10 @@ export class Signal extends Function {
|
|
|
205
205
|
/** Return the document id represented by this document signal. */
|
|
206
206
|
getId() {
|
|
207
207
|
const $root = getRoot(this) || this;
|
|
208
|
-
|
|
208
|
+
const rootId = $root?.[ROOT_ID];
|
|
209
|
+
return getSignalId(this, rootId, segments => (isPrivateSignalSegments(segments)
|
|
210
|
+
? getPrivateData(rootId, segments)
|
|
211
|
+
: _get(getSignalStorageSegments({ [SEGMENTS]: segments }))));
|
|
209
212
|
}
|
|
210
213
|
/** Return the public collection name this signal belongs to. */
|
|
211
214
|
getCollection() {
|
package/dist/orm/addModel.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { SignalClass } from './Signal.js';
|
|
2
|
-
import type { TeamplayModels } from '../index.js';
|
|
2
|
+
import type { TeamplayModels, TeamplayPluginModels } from '../index.js';
|
|
3
3
|
import type { PathSegment } from './types/path.js';
|
|
4
4
|
export declare const MODELS: Record<string, SignalClass<any>>;
|
|
5
|
-
|
|
5
|
+
type UnionToIntersection<TValue> = (TValue extends unknown ? (value: TValue) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
|
|
6
|
+
type RegistryValues<TRegistry> = TRegistry[keyof TRegistry & string];
|
|
7
|
+
type MergeRegistry<TRegistry> = [
|
|
8
|
+
RegistryValues<TRegistry>
|
|
9
|
+
] extends [never] ? {} : UnionToIntersection<RegistryValues<TRegistry>>;
|
|
10
|
+
type EffectiveTeamplayModels = TeamplayModels & MergeRegistry<TeamplayPluginModels>;
|
|
11
|
+
export default function addModel<TPattern extends string>(pattern: TPattern, Model: TPattern extends keyof EffectiveTeamplayModels ? EffectiveTeamplayModels[TPattern] : SignalClass<any>): void;
|
|
6
12
|
export declare function findModel(segments: PathSegment[]): SignalClass<any> | undefined;
|
|
13
|
+
export {};
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { belongsTo, hasMany, hasOne } from './associations.js';
|
|
2
|
-
export type { AggregationSignal, ArraySignal, CollectionAggregationSignal, CollectionQuerySignal, CollectionSignal, CollectionSignalFromSpec, CollectionSpec, CollectionsFromManifest, ComputedQueryParamsInput, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, ModelEntry, ModelManifest, PathModelsFromManifest, PublicSignal, RuntimeSignalConstructor, RuntimeSignalInstance, WildcardPathSegment, WildcardSignalPath, AppendPath, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, SignalBaseInstance, SignalClass, SignalChild, SignalConstructor, SignalForKind, SignalKind, SignalModelConstructor, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec } from './Signal.js';
|
|
3
|
-
export type { RootSignal, TeamplayCollections, TeamplayModels, TeamplaySignalFields } from '../index.js';
|
|
2
|
+
export type { AggregationSignal, ArraySignal, CollectionAggregationSignal, CollectionQuerySignal, CollectionSignal, CollectionSignalFromSpec, CollectionSpec, CollectionsFromManifest, ComputedQueryParamsInput, DocumentSignal, FromJsonSchema, JsonSchema, JsonSchemaSpec, ModelEntry, ModelManifest, PathModelsFromManifest, PrivateCollectionsFromManifest, PrivateSignalFromSpec, PublicSignal, RuntimeSignalConstructor, RuntimeSignalInstance, WildcardPathSegment, WildcardSignalPath, AppendPath, JoinPath, QueryParams, QueryParamsInput, QuerySignal, RegisteredAggregationInput, RootPrivateCollections, SignalBaseInstance, SignalClass, SignalChild, SignalConstructor, SignalForKind, SignalKind, SignalModelConstructor, TypedAggregationInput, TypedAggregationSignal, TypedSignal, ZodLikeSchema, ZodSchemaSpec } from './Signal.js';
|
|
3
|
+
export type { RootSignal, TeamplayCollections, TeamplayFeature, TeamplayFeatures, TeamplayModels, TeamplayPluginCollections, TeamplayPluginPrivateCollections, TeamplayPluginModels, TeamplayPluginOption, TeamplayPluginOptions, TeamplayPluginSignalFields, TeamplayPrivateCollections, TeamplaySignalFields } from '../index.js';
|
|
4
4
|
export declare const BaseModel: import("./Signal.js").SignalConstructor;
|
|
5
5
|
export default BaseModel;
|
|
6
6
|
export { defineModels, default as initModels, getModels, resetModelsForTests } from './initModels.js';
|
|
@@ -12,6 +12,6 @@ export declare function getSignalPath($signal: Pick<SignalMetadataOwner, typeof
|
|
|
12
12
|
export declare function getSignalLeaf($signal: Pick<SignalMetadataOwner, typeof SEGMENTS>): string;
|
|
13
13
|
export declare function getSignalParentSegments($signal: Pick<SignalMetadataOwner, typeof SEGMENTS>, levels: unknown, argumentCount: number): PathSegment[];
|
|
14
14
|
export declare function normalizeParentLevels(levels: unknown, argumentCount: number): number;
|
|
15
|
-
export declare function getSignalId($signal: Pick<SignalMetadataOwner, typeof SEGMENTS>, rootId?: string): string |
|
|
15
|
+
export declare function getSignalId($signal: Pick<SignalMetadataOwner, typeof SEGMENTS>, rootId?: string, readPath?: (segments: PathSegment[]) => unknown): string | undefined;
|
|
16
16
|
export declare function getSignalCollection($signal: SignalMetadataOwner): PathSegment | undefined;
|
|
17
17
|
export declare function getSignalAssociations($rawSignal: Pick<SignalMetadataOwner, 'constructor'>): readonly unknown[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AGGREGATIONS, getAggregationCollectionName, getAggregationDocId } from './Aggregation.js';
|
|
2
|
+
import { isPrivateCollectionSegments } from "./rootScope.js";
|
|
2
3
|
import { SEGMENTS } from "./signalSymbols.js";
|
|
3
4
|
export function getSignalPath($signal) {
|
|
4
5
|
return $signal[SEGMENTS].join('.');
|
|
@@ -27,16 +28,23 @@ export function normalizeParentLevels(levels, argumentCount) {
|
|
|
27
28
|
throw Error('Signal.parent() expects a positive integer');
|
|
28
29
|
return levels;
|
|
29
30
|
}
|
|
30
|
-
export function getSignalId($signal, rootId) {
|
|
31
|
+
export function getSignalId($signal, rootId, readPath) {
|
|
31
32
|
const segments = $signal[SEGMENTS];
|
|
32
33
|
if (segments.length === 0)
|
|
33
34
|
throw Error('Can\'t get the id of the root signal');
|
|
34
35
|
if (segments.length === 1)
|
|
35
36
|
throw Error('Can\'t get the id of a collection');
|
|
37
|
+
if (isDirectPublicDocumentSegments(segments))
|
|
38
|
+
return getLeafId(segments);
|
|
39
|
+
if (readPath) {
|
|
40
|
+
const valueId = getValueIdFromPaths(segments, readPath);
|
|
41
|
+
if (valueId.found)
|
|
42
|
+
return valueId.id;
|
|
43
|
+
}
|
|
36
44
|
if (segments[0] === AGGREGATIONS && segments.length === 3) {
|
|
37
45
|
return getAggregationDocId(segments, rootId);
|
|
38
46
|
}
|
|
39
|
-
return segments
|
|
47
|
+
return getLeafId(segments);
|
|
40
48
|
}
|
|
41
49
|
export function getSignalCollection($signal) {
|
|
42
50
|
const segments = $signal[SEGMENTS];
|
|
@@ -54,3 +62,21 @@ export function getSignalCollection($signal) {
|
|
|
54
62
|
export function getSignalAssociations($rawSignal) {
|
|
55
63
|
return $rawSignal.constructor.associations || [];
|
|
56
64
|
}
|
|
65
|
+
function getValueIdFromPaths(segments, readPath) {
|
|
66
|
+
const underscoreId = readPath([...segments, '_id']);
|
|
67
|
+
if (typeof underscoreId === 'string')
|
|
68
|
+
return { found: true, id: underscoreId };
|
|
69
|
+
const id = readPath([...segments, 'id']);
|
|
70
|
+
if (typeof id === 'string')
|
|
71
|
+
return { found: true, id };
|
|
72
|
+
if (underscoreId !== undefined || id !== undefined)
|
|
73
|
+
return { found: true };
|
|
74
|
+
return { found: false };
|
|
75
|
+
}
|
|
76
|
+
function isDirectPublicDocumentSegments(segments) {
|
|
77
|
+
return segments.length === 2 && !isPrivateCollectionSegments(segments);
|
|
78
|
+
}
|
|
79
|
+
function getLeafId(segments) {
|
|
80
|
+
const leaf = segments[segments.length - 1];
|
|
81
|
+
return typeof leaf === 'string' ? leaf : undefined;
|
|
82
|
+
}
|
|
@@ -21,6 +21,6 @@ export interface SignalReadContext<TSignal extends SignalReadOwner> {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function readSignalValue<TSignal extends SignalReadOwner, TValue>($signal: TSignal, context: SignalReadContext<TSignal>, method: SignalReadMethod<TValue>, rawMethod: SignalReadMethod): TValue;
|
|
23
23
|
export declare function getSignalValue<TSignal extends SignalReadOwner, TValue>($signal: TSignal, context: SignalReadContext<TSignal>, method: SignalReadMethod<TValue>, rawMethod: SignalReadMethod): TValue;
|
|
24
|
-
export declare function getSignalIds<TSignal extends SignalReadOwner>($signal: TSignal, context: SignalReadContext<TSignal>):
|
|
24
|
+
export declare function getSignalIds<TSignal extends SignalReadOwner>($signal: TSignal, context: SignalReadContext<TSignal>): string[];
|
|
25
25
|
export declare function isQueryIdsValueSignal<TSignal extends SignalReadOwner>($signal: TSignal): boolean;
|
|
26
26
|
export declare function isAggregationValueSignal<TSignal extends SignalReadOwner>($signal: TSignal): boolean;
|
package/dist/orm/signalReads.js
CHANGED
|
@@ -23,7 +23,7 @@ export function getSignalValue($signal, context, method, rawMethod) {
|
|
|
23
23
|
context.warn('Signal.get() on Query didn\'t find ids', $signal[SEGMENTS]);
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
|
-
return ids;
|
|
26
|
+
return ids.filter(isString);
|
|
27
27
|
}
|
|
28
28
|
return readSignalValue($signal, context, method, rawMethod);
|
|
29
29
|
}
|
|
@@ -35,13 +35,13 @@ export function getSignalIds($signal, context) {
|
|
|
35
35
|
context.warn('Signal.getIds() on Query didn\'t find ids', [QUERIES, getQueryHashSegment($signal), 'ids']);
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
|
-
return ids;
|
|
38
|
+
return ids.filter(isString);
|
|
39
39
|
}
|
|
40
40
|
if ($signal[IS_AGGREGATION]) {
|
|
41
41
|
const docs = context.readPrivateData(rootId, $signal[SEGMENTS], false);
|
|
42
42
|
if (!Array.isArray(docs))
|
|
43
43
|
return [];
|
|
44
|
-
return docs.map(getAggregationRowId);
|
|
44
|
+
return docs.map(getAggregationRowId).filter(isString);
|
|
45
45
|
}
|
|
46
46
|
context.error('Signal.getIds() can only be used on query signals or aggregation signals. ' +
|
|
47
47
|
'Received a regular signal: ' + JSON.stringify($signal[SEGMENTS]));
|
|
@@ -57,7 +57,13 @@ export function isAggregationValueSignal($signal) {
|
|
|
57
57
|
}
|
|
58
58
|
function getAggregationRowId(doc) {
|
|
59
59
|
const row = doc;
|
|
60
|
-
|
|
60
|
+
if (typeof row?._id === 'string')
|
|
61
|
+
return row._id;
|
|
62
|
+
if (typeof row?.id === 'string')
|
|
63
|
+
return row.id;
|
|
64
|
+
}
|
|
65
|
+
function isString(value) {
|
|
66
|
+
return typeof value === 'string';
|
|
61
67
|
}
|
|
62
68
|
function getQueryHashSegment($signal) {
|
|
63
69
|
return $signal[HASH];
|
|
@@ -6,7 +6,7 @@ export interface SignalMetadataMethods {
|
|
|
6
6
|
readonly [Symbol.toStringTag]: string;
|
|
7
7
|
parent: (levels?: number) => unknown;
|
|
8
8
|
id: () => string;
|
|
9
|
-
getId: () => string |
|
|
9
|
+
getId: () => string | undefined;
|
|
10
10
|
getCollection: () => string;
|
|
11
11
|
getAssociations: () => readonly unknown[];
|
|
12
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Signal as BaseSignal } from '../SignalBase.js';
|
|
2
2
|
import type { CollectionSpec, JsonSchemaSpec, SignalClass } from './signal.js';
|
|
3
|
+
import type { FromJsonSchema } from './jsonSchema.js';
|
|
3
4
|
export interface ModelEntry<TModel extends SignalClass<any> = SignalClass<any>, TSchema = unknown> {
|
|
4
5
|
default?: TModel;
|
|
5
6
|
schema?: TSchema;
|
|
@@ -8,10 +9,14 @@ export interface ModelEntry<TModel extends SignalClass<any> = SignalClass<any>,
|
|
|
8
9
|
}
|
|
9
10
|
export type ModelManifest = Record<string, ModelEntry>;
|
|
10
11
|
type StringKey<TValue> = Extract<keyof TValue, string>;
|
|
11
|
-
type CollectionManifestKey<TKey extends string> = TKey extends '' ? never : TKey extends `${string}.${string}` ? never : TKey extends `${string}*${string}` ? never : TKey;
|
|
12
|
+
type CollectionManifestKey<TKey extends string> = TKey extends '' ? never : TKey extends `_${string}` | `$${string}` ? never : TKey extends `${string}.${string}` ? never : TKey extends `${string}*${string}` ? never : TKey;
|
|
13
|
+
type PrivateCollectionManifestKey<TKey extends string> = TKey extends '' ? never : TKey extends `${string}.${string}` ? never : TKey extends `${string}*${string}` ? never : TKey extends `_${string}` | `$${string}` ? TKey : never;
|
|
12
14
|
type CollectionManifestKeys<TModels> = {
|
|
13
15
|
[K in StringKey<TModels>]: CollectionManifestKey<K>;
|
|
14
16
|
}[StringKey<TModels>];
|
|
17
|
+
type PrivateCollectionManifestKeys<TModels> = {
|
|
18
|
+
[K in StringKey<TModels>]: PrivateCollectionManifestKey<K>;
|
|
19
|
+
}[StringKey<TModels>];
|
|
15
20
|
type ModelPathManifestKey<TKey extends string> = TKey extends '' ? never : TKey extends `${string}*${string}` ? TKey : never;
|
|
16
21
|
type ModelPathManifestKeys<TModels> = {
|
|
17
22
|
[K in StringKey<TModels>]: ModelPathManifestKey<K>;
|
|
@@ -26,9 +31,15 @@ type SchemaFromEntry<TEntry> = TEntry extends {
|
|
|
26
31
|
type CollectionSpecFromManifestEntry<TModels, TCollection extends string> = [
|
|
27
32
|
SchemaFromEntry<ManifestEntry<TModels, TCollection>>
|
|
28
33
|
] extends [never] ? CollectionSpec<unknown, ModelFromEntry<ManifestEntry<TModels, TCollection>>, ModelFromEntry<ManifestEntry<TModels, `${TCollection}.*`>>> : JsonSchemaSpec<SchemaFromEntry<ManifestEntry<TModels, TCollection>>, ModelFromEntry<ManifestEntry<TModels, TCollection>>, ModelFromEntry<ManifestEntry<TModels, `${TCollection}.*`>>>;
|
|
34
|
+
type PrivateCollectionValueFromManifestEntry<TModels, TCollection extends string> = [
|
|
35
|
+
SchemaFromEntry<ManifestEntry<TModels, TCollection>>
|
|
36
|
+
] extends [never] ? unknown : FromJsonSchema<SchemaFromEntry<ManifestEntry<TModels, TCollection>>>;
|
|
29
37
|
export type CollectionsFromManifest<TModels extends Record<string, any>> = {
|
|
30
38
|
[K in CollectionManifestKeys<TModels>]: CollectionSpecFromManifestEntry<TModels, K>;
|
|
31
39
|
};
|
|
40
|
+
export type PrivateCollectionsFromManifest<TModels extends Record<string, any>> = {
|
|
41
|
+
[K in PrivateCollectionManifestKeys<TModels>]: PrivateCollectionValueFromManifestEntry<TModels, K>;
|
|
42
|
+
};
|
|
32
43
|
export type PathModelsFromManifest<TModels extends Record<string, any>> = {
|
|
33
44
|
[K in ModelPathManifestKeys<TModels> as ManifestEntry<TModels, K> extends {
|
|
34
45
|
default: any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TeamplayCollections, TeamplayModels, TeamplaySignalFields } from '../../index.js';
|
|
1
|
+
import type { TeamplayCollections, TeamplayPrivateCollections, TeamplayPluginPrivateCollections, TeamplayModels, TeamplayPluginCollections, TeamplayPluginModels, TeamplayPluginSignalFields, TeamplaySignalFields } from '../../index.js';
|
|
2
2
|
import type { Signal, GETTERS } from '../SignalBase.js';
|
|
3
3
|
import type { FromJsonSchema, InferZodSchema, JsonSchema, ZodLikeSchema } from './jsonSchema.js';
|
|
4
4
|
import type { AppendPath, JoinPath, PathSegment, WildcardSignalPath } from './path.js';
|
|
@@ -20,11 +20,29 @@ type SignalQueryMethodKeys = SignalArrayReaderMethodKeys | SignalArrayMutatorMet
|
|
|
20
20
|
type BlockedArrayMutators = {
|
|
21
21
|
readonly [K in SignalArrayMutatorMethodKeys]?: never;
|
|
22
22
|
};
|
|
23
|
+
type UnionToIntersection<TValue> = (TValue extends unknown ? (value: TValue) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
|
|
24
|
+
type RegistryValues<TRegistry> = TRegistry[keyof TRegistry & string];
|
|
25
|
+
type MergeRegistry<TRegistry> = [
|
|
26
|
+
RegistryValues<TRegistry>
|
|
27
|
+
] extends [never] ? {} : UnionToIntersection<RegistryValues<TRegistry>>;
|
|
28
|
+
type EffectiveTeamplayCollections = TeamplayCollections & MergeRegistry<TeamplayPluginCollections>;
|
|
29
|
+
type EffectiveTeamplayPrivateCollections = TeamplayPrivateCollections & MergeRegistry<TeamplayPluginPrivateCollections>;
|
|
30
|
+
type EffectiveTeamplayModels = TeamplayModels & MergeRegistry<TeamplayPluginModels>;
|
|
31
|
+
type EffectiveTeamplaySignalFields = TeamplaySignalFields & MergeRegistry<TeamplayPluginSignalFields>;
|
|
32
|
+
type RootDollarAliases = {
|
|
33
|
+
readonly session: '_session';
|
|
34
|
+
readonly page: '_page';
|
|
35
|
+
readonly render: '$render';
|
|
36
|
+
readonly system: '$system';
|
|
37
|
+
};
|
|
23
38
|
type SignalArrayLike<TItem> = SignalArrayReaderMethods<TItem>;
|
|
24
|
-
type PathModel<TValue, TDefaultModel extends SignalClass<any>, TPath extends WildcardSignalPath> = JoinPath<TPath> extends keyof
|
|
39
|
+
type PathModel<TValue, TDefaultModel extends SignalClass<any>, TPath extends WildcardSignalPath> = JoinPath<TPath> extends keyof EffectiveTeamplayModels ? EffectiveTeamplayModels[JoinPath<TPath>] extends SignalClass<TValue> ? EffectiveTeamplayModels[JoinPath<TPath>] : EffectiveTeamplayModels[JoinPath<TPath>] extends SignalClass<any> ? EffectiveTeamplayModels[JoinPath<TPath>] : TDefaultModel : TDefaultModel;
|
|
25
40
|
type ArrayItemSignal<Item, TPath extends WildcardSignalPath> = DocumentSignal<Item, typeof Signal, AppendPath<TPath, '*'>>;
|
|
26
41
|
type SignalArrayMethods<TValue, TPath extends WildcardSignalPath> = NonNullable<TValue> extends ReadonlyArray<infer Item> ? SignalArrayLike<ArrayItemSignal<Item, TPath>> : Pick<Signal<TValue>, SignalArrayReaderMethodKeys>;
|
|
27
|
-
type SignalFieldsForPath<TPath extends WildcardSignalPath> = JoinPath<TPath> extends keyof
|
|
42
|
+
type SignalFieldsForPath<TPath extends WildcardSignalPath> = JoinPath<TPath> extends keyof EffectiveTeamplaySignalFields ? EffectiveTeamplaySignalFields[JoinPath<TPath>] : {};
|
|
43
|
+
type DocumentSignalIdMethod = {
|
|
44
|
+
getId: () => string;
|
|
45
|
+
};
|
|
28
46
|
export type AnySignal = Signal<any>;
|
|
29
47
|
type IsAny<TValue> = 0 extends (1 & TValue) ? true : false;
|
|
30
48
|
type IsUnknown<TValue> = IsAny<TValue> extends true ? false : unknown extends TValue ? true : false;
|
|
@@ -34,7 +52,7 @@ type IsUnion<TValue, TUnion = TValue> = [
|
|
|
34
52
|
] extends [never] ? false : TValue extends unknown ? [TUnion] extends [TValue] ? false : true : false;
|
|
35
53
|
type SingleKey<TKey> = IsUnion<TKey> extends true ? never : TKey;
|
|
36
54
|
export type SignalKind = 'root' | 'document' | 'collection' | 'nestedValue' | 'localArray' | 'array' | 'query' | 'aggregation' | 'collectionQuery';
|
|
37
|
-
type DocumentSignalForKind<TValue, TModel extends SignalClass<any>, TPath extends WildcardSignalPath> = Omit<SignalModelInstance<TValue, PathModel<TValue, TModel, TPath>>, SignalArrayReaderMethodKeys> & SignalArrayMethods<TValue, TPath> & SignalChildren<TValue, TPath> & SignalFieldsForPath<TPath>;
|
|
55
|
+
type DocumentSignalForKind<TValue, TModel extends SignalClass<any>, TPath extends WildcardSignalPath> = Omit<SignalModelInstance<TValue, PathModel<TValue, TModel, TPath>>, SignalArrayReaderMethodKeys | 'getId'> & DocumentSignalIdMethod & SignalArrayMethods<TValue, TPath> & SignalChildren<TValue, TPath> & SignalFieldsForPath<TPath>;
|
|
38
56
|
type CollectionSignalForKind<TDocument, TCollectionModel extends SignalClass<any>, TDocumentModel extends SignalClass<any>, TPath extends WildcardSignalPath> = Omit<SignalModelInstance<TDocument[], PathModel<TDocument[], TCollectionModel, TPath>>, SignalCollectionMethodKeys> & SignalArrayLike<CollectionDocumentSignal<TDocument, TDocumentModel, TPath>> & BlockedArrayMutators & {
|
|
39
57
|
add: (value: TDocument) => Promise<string>;
|
|
40
58
|
} & CollectionDocumentIndex<CollectionDocumentSignal<TDocument, TDocumentModel, TPath>>;
|
|
@@ -43,7 +61,7 @@ type ArraySignalForKind<TDocument, TDocumentModel extends SignalClass<any>, TDoc
|
|
|
43
61
|
readonly [index: number]: DocumentSignal<TDocument, TDocumentModel, TDocumentPath>;
|
|
44
62
|
} & BlockedArrayMutators;
|
|
45
63
|
type QueryMetadataSignals = {
|
|
46
|
-
readonly ids: Signal<
|
|
64
|
+
readonly ids: Signal<string[]>;
|
|
47
65
|
readonly extra: Signal<unknown>;
|
|
48
66
|
};
|
|
49
67
|
type QuerySignalForKind<TDocument, TDocumentModel extends SignalClass<any>, TDocumentPath extends WildcardSignalPath> = ArraySignalForKind<TDocument, TDocumentModel, TDocumentPath> & QueryMetadataSignals;
|
|
@@ -59,22 +77,22 @@ export type CollectionDocument<TSpec> = TSpec extends CollectionSpec<infer Docum
|
|
|
59
77
|
export type CollectionDocumentModel<TSpec> = TSpec extends CollectionSpec<any, any, infer DocumentModel> ? DocumentModel : typeof Signal;
|
|
60
78
|
export type CollectionQuerySignal<TDocument, TCollectionModel extends SignalClass<any>, TDocumentModel extends SignalClass<any>, TCollectionPath extends WildcardSignalPath> = CollectionSignalForKind<TDocument, TCollectionModel, TDocumentModel, TCollectionPath> & QueryMetadataSignals;
|
|
61
79
|
type MatchingDocumentCollectionKeys<TValue> = IsAny<TValue> extends true ? never : {
|
|
62
|
-
[K in keyof
|
|
63
|
-
}[keyof
|
|
80
|
+
[K in keyof EffectiveTeamplayCollections & string]: IsEqual<NonNullable<TValue>, NonNullable<CollectionDocument<EffectiveTeamplayCollections[K]>>> extends true ? K : never;
|
|
81
|
+
}[keyof EffectiveTeamplayCollections & string];
|
|
64
82
|
type MatchingCollectionKeys<TValue> = IsAny<TValue> extends true ? never : NonNullable<TValue> extends ReadonlyArray<infer TDocument> ? MatchingDocumentCollectionKeys<TDocument> : never;
|
|
65
83
|
type SingleDocumentCollectionKey<TValue> = SingleKey<MatchingDocumentCollectionKeys<TValue>>;
|
|
66
84
|
type SingleCollectionKey<TValue> = SingleKey<MatchingCollectionKeys<TValue>>;
|
|
67
85
|
type DocumentSignalModelForValue<TValue> = [
|
|
68
86
|
SingleDocumentCollectionKey<TValue>
|
|
69
|
-
] extends [never] ? typeof Signal : SingleDocumentCollectionKey<TValue> extends keyof
|
|
87
|
+
] extends [never] ? typeof Signal : SingleDocumentCollectionKey<TValue> extends keyof EffectiveTeamplayCollections & string ? CollectionDocumentModel<EffectiveTeamplayCollections[SingleDocumentCollectionKey<TValue>]> : typeof Signal;
|
|
70
88
|
type DocumentSignalPathForValue<TValue> = [
|
|
71
89
|
SingleDocumentCollectionKey<TValue>
|
|
72
|
-
] extends [never] ? readonly [] : SingleDocumentCollectionKey<TValue> extends keyof
|
|
90
|
+
] extends [never] ? readonly [] : SingleDocumentCollectionKey<TValue> extends keyof EffectiveTeamplayCollections & string ? readonly [SingleDocumentCollectionKey<TValue>, '*'] : readonly [];
|
|
73
91
|
type SignalForDocumentValue<TValue> = TypedSignal<TValue, DocumentSignalModelForValue<TValue>, DocumentSignalPathForValue<TValue>>;
|
|
74
|
-
type SignalForCollectionArrayValue<TCollection extends keyof
|
|
92
|
+
type SignalForCollectionArrayValue<TCollection extends keyof EffectiveTeamplayCollections & string> = CollectionSignal<CollectionDocument<EffectiveTeamplayCollections[TCollection]>, EffectiveTeamplayCollections[TCollection] extends CollectionSpec<any, infer CollectionModel, any> ? CollectionModel : typeof Signal, CollectionDocumentModel<EffectiveTeamplayCollections[TCollection]>, readonly [TCollection]>;
|
|
75
93
|
type SignalForArrayValue<TValue> = [
|
|
76
94
|
SingleCollectionKey<TValue>
|
|
77
|
-
] extends [never] ? SignalForDocumentValue<TValue> : SingleCollectionKey<TValue> extends keyof
|
|
95
|
+
] extends [never] ? SignalForDocumentValue<TValue> : SingleCollectionKey<TValue> extends keyof EffectiveTeamplayCollections & string ? SignalForCollectionArrayValue<SingleCollectionKey<TValue>> : SignalForDocumentValue<TValue>;
|
|
78
96
|
export type PublicSignal<TValue = unknown> = IsAny<TValue> extends true ? TypedSignal<TValue> : NonNullable<TValue> extends ReadonlyArray<any> ? SignalForArrayValue<TValue> : SignalForDocumentValue<TValue>;
|
|
79
97
|
export interface LocalSignalFactory {
|
|
80
98
|
(): any;
|
|
@@ -82,12 +100,12 @@ export interface LocalSignalFactory {
|
|
|
82
100
|
<TValue>(factory: () => TValue): TypedSignal<TValue>;
|
|
83
101
|
<TValue>(value: TValue): TypedSignal<TValue>;
|
|
84
102
|
}
|
|
85
|
-
export type RootCollections<TCollections
|
|
103
|
+
export type RootCollections<TCollections = EffectiveTeamplayCollections> = {
|
|
86
104
|
readonly [K in keyof TCollections & string]: CollectionSignalFromSpec<TCollections[K], readonly [K]>;
|
|
87
105
|
} & {
|
|
88
106
|
readonly [K in keyof TCollections & string as `$${K}`]: CollectionSignalFromSpec<TCollections[K], readonly [K]>;
|
|
89
107
|
};
|
|
90
|
-
export type RootSignal<TCollections
|
|
108
|
+
export type RootSignal<TCollections = EffectiveTeamplayCollections> = Signal<Record<string, unknown>> & LocalSignalFactory & RootCollections<TCollections> & RootPrivateCollections;
|
|
91
109
|
export interface RegisteredAggregationInput<TCollection extends string = string, TOutput = unknown> {
|
|
92
110
|
readonly __isAggregation: true;
|
|
93
111
|
readonly collection: TCollection;
|
|
@@ -98,10 +116,10 @@ export interface TypedAggregationInput<TDocument = unknown, TDocumentModel exten
|
|
|
98
116
|
readonly __teamplayDocument?: TDocument;
|
|
99
117
|
readonly __teamplayDocumentModel?: TDocumentModel;
|
|
100
118
|
}
|
|
101
|
-
export type CollectionAggregationSignal<TCollection extends keyof
|
|
119
|
+
export type CollectionAggregationSignal<TCollection extends keyof EffectiveTeamplayCollections & string> = AggregationSignal<CollectionDocument<EffectiveTeamplayCollections[TCollection]>, CollectionDocumentModel<EffectiveTeamplayCollections[TCollection]>, readonly [TCollection, '*']>;
|
|
102
120
|
export type TypedAggregationSignal<TDocument, TDocumentModel extends SignalClass<any>> = AggregationSignal<TDocument, TDocumentModel>;
|
|
103
121
|
export type AggregationOutputSignal<TOutput> = IsAny<TOutput> extends true ? QuerySignal : NonNullable<TOutput> extends ReadonlyArray<infer TDocument> ? AggregationSignal<TDocument, DocumentSignalModelForValue<TDocument>, DocumentSignalPathForValue<TDocument>> : SignalForDocumentValue<TOutput>;
|
|
104
|
-
type RegisteredAggregationSignal<TCollection extends string, TOutput> = IsUnknown<TOutput> extends true ? TCollection extends keyof
|
|
122
|
+
type RegisteredAggregationSignal<TCollection extends string, TOutput> = IsUnknown<TOutput> extends true ? TCollection extends keyof EffectiveTeamplayCollections & string ? CollectionAggregationSignal<TCollection> : QuerySignal : AggregationOutputSignal<TOutput>;
|
|
105
123
|
export type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
106
124
|
export type SubResult<TSignal, TParams = undefined> = TSignal extends ClientAggregationFunction<infer TOutput, infer TCollection> ? RegisteredAggregationSignal<TCollection, TOutput> : TSignal extends AggregationFunction<infer TOutput, any> ? IsUnknown<TOutput> extends true ? QuerySignal : AggregationOutputSignal<TOutput> : TSignal extends TypedAggregationInput<infer TDocument, infer TDocumentModel> ? TypedAggregationSignal<TDocument, TDocumentModel> : TSignal extends RegisteredAggregationInput<infer TCollection, infer TOutput> ? RegisteredAggregationSignal<TCollection, TOutput> : [TParams] extends [undefined] ? TSignal extends DocumentSignal<any, any, any> ? TSignal : QuerySignal : TSignal extends CollectionSignal<infer TDocument, infer TCollectionModel, infer TDocumentModel, infer TCollectionPath> ? CollectionQuerySignal<TDocument, TCollectionModel, TDocumentModel, TCollectionPath> : QuerySignal;
|
|
107
125
|
export type MaybePromiseSubResult<TSignal, TParams = undefined> = MaybePromise<SubResult<TSignal, TParams>>;
|
|
@@ -121,6 +139,17 @@ export interface CollectionSpec<TDocument = unknown, TCollectionModel extends Si
|
|
|
121
139
|
export type JsonSchemaSpec<TSchema, TCollectionModel extends SignalClass<any> = typeof Signal, TDocumentModel extends SignalClass<any> = typeof Signal> = CollectionSpec<FromJsonSchema<TSchema>, TCollectionModel, TDocumentModel>;
|
|
122
140
|
export type ZodSchemaSpec<TSchema extends ZodLikeSchema, TCollectionModel extends SignalClass<any> = typeof Signal, TDocumentModel extends SignalClass<any> = typeof Signal> = CollectionSpec<InferZodSchema<TSchema>, TCollectionModel, TDocumentModel>;
|
|
123
141
|
export type CollectionSignalFromSpec<TSpec, TPath extends WildcardSignalPath = readonly []> = TSpec extends CollectionSpec<infer Document, infer CollectionModel, infer DocumentModel> ? CollectionSignal<Document, CollectionModel, DocumentModel, TPath> : TSpec extends JsonSchema ? CollectionSignal<FromJsonSchema<TSpec>, typeof Signal, typeof Signal, TPath> : CollectionSignal;
|
|
142
|
+
export type PrivateSignalFromSpec<TSpec, TPath extends WildcardSignalPath = readonly []> = Omit<DocumentSignal<TSpec, typeof Signal, TPath>, 'add'>;
|
|
143
|
+
type PrivateSignalForAlias<TPrivateCollections, TAlias extends keyof RootDollarAliases & string> = RootDollarAliases[TAlias] extends keyof TPrivateCollections & string ? PrivateSignalFromSpec<TPrivateCollections[RootDollarAliases[TAlias]], readonly [RootDollarAliases[TAlias]]> : never;
|
|
144
|
+
export type RootPrivateCollections<TPrivateCollections = EffectiveTeamplayPrivateCollections> = {
|
|
145
|
+
readonly [K in keyof TPrivateCollections & string]: PrivateSignalFromSpec<TPrivateCollections[K], readonly [K]>;
|
|
146
|
+
} & {
|
|
147
|
+
readonly [K in keyof TPrivateCollections & string as `$${K}`]: PrivateSignalFromSpec<TPrivateCollections[K], readonly [K]>;
|
|
148
|
+
} & {
|
|
149
|
+
readonly [K in keyof RootDollarAliases & string as RootDollarAliases[K] extends keyof TPrivateCollections & string ? K : never]: PrivateSignalForAlias<TPrivateCollections, K>;
|
|
150
|
+
} & {
|
|
151
|
+
readonly [K in keyof RootDollarAliases & string as RootDollarAliases[K] extends keyof TPrivateCollections & string ? `$${K}` : never]: PrivateSignalForAlias<TPrivateCollections, K>;
|
|
152
|
+
};
|
|
124
153
|
export interface SignalConstructor {
|
|
125
154
|
new <TValue = unknown>(segments: PathSegment[]): TypedSignal<TValue>;
|
|
126
155
|
readonly ID_FIELDS: typeof Signal.ID_FIELDS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.5",
|
|
4
4
|
"description": "Full-stack signals ORM with multiplayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@nx-js/observer-util": "^4.1.3",
|
|
71
71
|
"@startupjs/sharedb-mingo-memory": "^4.0.0-2",
|
|
72
|
-
"@teamplay/backend": "^0.5.0-alpha.
|
|
72
|
+
"@teamplay/backend": "^0.5.0-alpha.5",
|
|
73
73
|
"@teamplay/cache": "^0.5.0-alpha.0",
|
|
74
74
|
"@teamplay/channel": "^0.5.0-alpha.0",
|
|
75
75
|
"@teamplay/debug": "^0.5.0-alpha.0",
|
|
76
76
|
"@teamplay/schema": "^0.5.0-alpha.1",
|
|
77
|
-
"@teamplay/utils": "^0.5.0-alpha.
|
|
78
|
-
"babel-plugin-teamplay": "^0.5.0-alpha.
|
|
77
|
+
"@teamplay/utils": "^0.5.0-alpha.5",
|
|
78
|
+
"babel-plugin-teamplay": "^0.5.0-alpha.5",
|
|
79
79
|
"diff-match-patch": "^1.0.5",
|
|
80
80
|
"events": "^3.3.0",
|
|
81
81
|
"json0-ot-diff": "^1.1.2",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
]
|
|
129
129
|
},
|
|
130
130
|
"license": "MIT",
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "4527ba386f4994295901c4b4e30c5eaf42739103"
|
|
132
132
|
}
|