@contember/bindx 0.1.5 → 0.1.9
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/adapter/ContemberAdapter.d.ts +11 -14
- package/dist/adapter/ContemberAdapter.d.ts.map +1 -1
- package/dist/brand/ComponentBrand.d.ts +1 -24
- package/dist/brand/ComponentBrand.d.ts.map +1 -1
- package/dist/contember/index.d.ts +1 -2
- package/dist/contember/index.d.ts.map +1 -1
- package/dist/handles/EntityHandle.d.ts +18 -29
- package/dist/handles/EntityHandle.d.ts.map +1 -1
- package/dist/handles/FieldHandle.d.ts +5 -3
- package/dist/handles/FieldHandle.d.ts.map +1 -1
- package/dist/handles/HasManyListHandle.d.ts +4 -3
- package/dist/handles/HasManyListHandle.d.ts.map +1 -1
- package/dist/handles/HasOneHandle.d.ts +33 -36
- package/dist/handles/HasOneHandle.d.ts.map +1 -1
- package/dist/handles/PlaceholderHandle.d.ts +9 -19
- package/dist/handles/PlaceholderHandle.d.ts.map +1 -1
- package/dist/handles/proxyFactory.d.ts +9 -37
- package/dist/handles/proxyFactory.d.ts.map +1 -1
- package/dist/handles/types.d.ts +4 -0
- package/dist/handles/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/persistence/ContemberSchemaMutationAdapter.d.ts +24 -1
- package/dist/persistence/ContemberSchemaMutationAdapter.d.ts.map +1 -1
- package/dist/schema/ContemberSchema.d.ts +1 -97
- package/dist/schema/ContemberSchema.d.ts.map +1 -1
- package/dist/schema/SchemaLoader.d.ts +1 -27
- package/dist/schema/SchemaLoader.d.ts.map +1 -1
- package/dist/schema/SchemaRegistry.d.ts +1 -94
- package/dist/schema/SchemaRegistry.d.ts.map +1 -1
- package/dist/schema/roles.d.ts +1 -61
- package/dist/schema/roles.d.ts.map +1 -1
- package/dist/schema/types.d.ts +1 -178
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/selection/SelectionMetaCollector.d.ts +1 -31
- package/dist/selection/SelectionMetaCollector.d.ts.map +1 -1
- package/dist/selection/SelectionScope.d.ts +1 -76
- package/dist/selection/SelectionScope.d.ts.map +1 -1
- package/dist/selection/buildQuery.d.ts +1 -44
- package/dist/selection/buildQuery.d.ts.map +1 -1
- package/dist/selection/createFragment.d.ts +1 -28
- package/dist/selection/createFragment.d.ts.map +1 -1
- package/dist/selection/createSelectionBuilder.d.ts +1 -17
- package/dist/selection/createSelectionBuilder.d.ts.map +1 -1
- package/dist/selection/queryTypes.d.ts +1 -83
- package/dist/selection/queryTypes.d.ts.map +1 -1
- package/dist/selection/types.d.ts +1 -237
- package/dist/selection/types.d.ts.map +1 -1
- package/dist/utils/aliasGenerator.d.ts +1 -24
- package/dist/utils/aliasGenerator.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/adapter/ContemberAdapter.ts +193 -123
- package/src/brand/ComponentBrand.ts +1 -28
- package/src/contember/index.ts +1 -8
- package/src/handles/EntityHandle.ts +131 -61
- package/src/handles/FieldHandle.ts +19 -3
- package/src/handles/HasManyListHandle.ts +15 -12
- package/src/handles/HasOneHandle.ts +98 -66
- package/src/handles/PlaceholderHandle.ts +26 -24
- package/src/handles/proxyFactory.ts +29 -128
- package/src/handles/types.ts +6 -0
- package/src/index.ts +22 -3
- package/src/persistence/ContemberSchemaMutationAdapter.ts +19 -1
- package/src/schema/ContemberSchema.ts +14 -132
- package/src/schema/SchemaLoader.ts +1 -93
- package/src/schema/SchemaRegistry.ts +1 -286
- package/src/schema/roles.ts +10 -83
- package/src/schema/types.ts +21 -238
- package/src/selection/SelectionMetaCollector.ts +1 -122
- package/src/selection/SelectionScope.ts +1 -208
- package/src/selection/buildQuery.ts +1 -134
- package/src/selection/createFragment.ts +1 -50
- package/src/selection/createSelectionBuilder.ts +1 -283
- package/src/selection/queryTypes.ts +8 -135
- package/src/selection/types.ts +13 -320
- package/src/utils/aliasGenerator.ts +1 -56
package/dist/schema/types.d.ts
CHANGED
|
@@ -1,179 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Schema type definitions for bindx.
|
|
3
|
-
* Provides type-safe entity and relation definitions.
|
|
4
|
-
*/
|
|
5
|
-
import type { CommonEntity, SingleRoleMap } from './roles.js';
|
|
6
|
-
/**
|
|
7
|
-
* Relation type discriminator
|
|
8
|
-
*/
|
|
9
|
-
export type RelationType = 'hasOne' | 'hasMany';
|
|
10
|
-
/**
|
|
11
|
-
* Scalar field definition
|
|
12
|
-
*/
|
|
13
|
-
export interface ScalarFieldDef {
|
|
14
|
-
readonly type: 'scalar';
|
|
15
|
-
readonly columnType?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Enum scalar field definition — carries the allowed values at runtime
|
|
19
|
-
*/
|
|
20
|
-
export interface EnumFieldDef {
|
|
21
|
-
readonly type: 'enum';
|
|
22
|
-
readonly enumName: string;
|
|
23
|
-
readonly values: readonly string[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Has-one relation definition
|
|
27
|
-
*/
|
|
28
|
-
export interface HasOneRelationDef<TTarget extends string = string> {
|
|
29
|
-
readonly type: 'hasOne';
|
|
30
|
-
readonly target: TTarget;
|
|
31
|
-
/** Inverse field name on the target entity (for bidirectional relations) */
|
|
32
|
-
readonly inverse?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Has-many relation definition
|
|
36
|
-
*/
|
|
37
|
-
export interface HasManyRelationDef<TTarget extends string = string> {
|
|
38
|
-
readonly type: 'hasMany';
|
|
39
|
-
readonly target: TTarget;
|
|
40
|
-
/** Inverse field name on the target entity (for bidirectional relations) */
|
|
41
|
-
readonly inverse?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Union of all field definition types
|
|
45
|
-
*/
|
|
46
|
-
export type FieldDef<TTarget extends string = string> = ScalarFieldDef | EnumFieldDef | HasOneRelationDef<TTarget> | HasManyRelationDef<TTarget>;
|
|
47
|
-
/**
|
|
48
|
-
* Entity schema definition - maps field names to their definitions
|
|
49
|
-
*/
|
|
50
|
-
export interface EntitySchemaDef<TEntityNames extends string = string> {
|
|
51
|
-
readonly fields: Record<string, FieldDef<TEntityNames>>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Complete schema definition mapping entity names to their schemas.
|
|
55
|
-
* TModels provides the TypeScript types for each entity.
|
|
56
|
-
*/
|
|
57
|
-
export interface SchemaDefinition<TModels extends {
|
|
58
|
-
[K in keyof TModels]: object;
|
|
59
|
-
}, TEntityNames extends string = keyof TModels & string> {
|
|
60
|
-
readonly entities: {
|
|
61
|
-
[K in TEntityNames]: EntitySchemaDef<TEntityNames>;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Helper function to create a scalar field definition
|
|
66
|
-
*/
|
|
67
|
-
export declare function scalar(): ScalarFieldDef;
|
|
68
|
-
/**
|
|
69
|
-
* Helper function to create an enum scalar field definition with allowed values.
|
|
70
|
-
*/
|
|
71
|
-
export declare function enumScalar<T extends string>(enumName: string, values: readonly T[]): EnumFieldDef;
|
|
72
|
-
/**
|
|
73
|
-
* Helper function to create a has-one relation definition
|
|
74
|
-
*/
|
|
75
|
-
export declare function hasOne<TTarget extends string>(target: TTarget, options?: {
|
|
76
|
-
inverse?: string;
|
|
77
|
-
}): HasOneRelationDef<TTarget>;
|
|
78
|
-
/**
|
|
79
|
-
* Helper function to create a has-many relation definition
|
|
80
|
-
*/
|
|
81
|
-
export declare function hasMany<TTarget extends string>(target: TTarget, options?: {
|
|
82
|
-
inverse?: string;
|
|
83
|
-
}): HasManyRelationDef<TTarget>;
|
|
84
|
-
/**
|
|
85
|
-
* Helper function to define a complete schema with full type inference.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
* interface Author {
|
|
90
|
-
* id: string
|
|
91
|
-
* name: string
|
|
92
|
-
* articles: Article[]
|
|
93
|
-
* }
|
|
94
|
-
*
|
|
95
|
-
* interface Article {
|
|
96
|
-
* id: string
|
|
97
|
-
* title: string
|
|
98
|
-
* author: Author
|
|
99
|
-
* }
|
|
100
|
-
*
|
|
101
|
-
* const schema = defineSchema<{
|
|
102
|
-
* Author: Author
|
|
103
|
-
* Article: Article
|
|
104
|
-
* }>({
|
|
105
|
-
* entities: {
|
|
106
|
-
* Author: {
|
|
107
|
-
* fields: {
|
|
108
|
-
* id: scalar(),
|
|
109
|
-
* name: scalar(),
|
|
110
|
-
* articles: hasMany('Article', { inverse: 'author' })
|
|
111
|
-
* }
|
|
112
|
-
* },
|
|
113
|
-
* Article: {
|
|
114
|
-
* fields: {
|
|
115
|
-
* id: scalar(),
|
|
116
|
-
* title: scalar(),
|
|
117
|
-
* author: hasOne('Author', { inverse: 'articles' })
|
|
118
|
-
* }
|
|
119
|
-
* }
|
|
120
|
-
* }
|
|
121
|
-
* })
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
export declare function defineSchema<TModels extends {
|
|
125
|
-
[K in keyof TModels]: object;
|
|
126
|
-
}>(definition: SchemaDefinition<TModels>): SchemaDefinition<TModels>;
|
|
127
|
-
/**
|
|
128
|
-
* Infers the model type for a given entity name from a schema
|
|
129
|
-
*/
|
|
130
|
-
export type InferModel<TSchema extends SchemaDefinition<any>, TEntityName extends keyof TSchema['entities']> = TSchema extends SchemaDefinition<infer TModels> ? TEntityName extends keyof TModels ? TModels[TEntityName] : never : never;
|
|
131
|
-
/**
|
|
132
|
-
* Infers all entity names from a schema
|
|
133
|
-
*/
|
|
134
|
-
export type InferEntityNames<TSchema extends SchemaDefinition<any>> = keyof TSchema['entities'] & string;
|
|
135
|
-
/**
|
|
136
|
-
* A type-safe reference to an entity in the schema.
|
|
137
|
-
* Carries a role map as a phantom type parameter: Record<roleName, entityType>.
|
|
138
|
-
*
|
|
139
|
-
* For schemas without ACL, the role map is `{ _default: TEntity }`.
|
|
140
|
-
* For schemas with ACL, each role maps to a per-role entity type.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* // Without roles (convenience):
|
|
145
|
-
* const Article = entityDef<ArticleType>('Article') // → EntityDef<{ _default: ArticleType }>
|
|
146
|
-
*
|
|
147
|
-
* // With roles (generator):
|
|
148
|
-
* const Article = roleEntityDef<{ admin: Article$admin; public: Article$public }>('Article')
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
export interface EntityDef<TRoleMap extends Record<string, object> = Record<string, object>> {
|
|
152
|
-
readonly $name: string;
|
|
153
|
-
/** @internal phantom type for role map — not present at runtime */
|
|
154
|
-
readonly $roleMap?: TRoleMap;
|
|
155
|
-
/** @internal reference to the schema definition for collection-time field lookups */
|
|
156
|
-
readonly $schema?: SchemaDefinition<Record<string, object>>;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Infers the common (default) entity type from an EntityDef.
|
|
160
|
-
* Returns the union of all role entity types — only common fields are accessible.
|
|
161
|
-
*/
|
|
162
|
-
export type InferEntityDef<T> = T extends EntityDef<infer TRoleMap> ? CommonEntity<TRoleMap> : never;
|
|
163
|
-
/**
|
|
164
|
-
* Creates a type-safe entity definition reference.
|
|
165
|
-
* Wraps the entity type in a single-role map: `{ _default: TEntity }`.
|
|
166
|
-
*
|
|
167
|
-
* @param name - The entity name as used in the schema
|
|
168
|
-
* @param schema - Optional schema definition for collection-time field lookups
|
|
169
|
-
*/
|
|
170
|
-
export declare function entityDef<TEntity extends object>(name: string, schema?: SchemaDefinition<Record<string, object>>): EntityDef<SingleRoleMap<TEntity>>;
|
|
171
|
-
/**
|
|
172
|
-
* Creates a role-aware entity definition reference.
|
|
173
|
-
* Used by the generator when ACL roles are present.
|
|
174
|
-
*
|
|
175
|
-
* @param name - The entity name as used in the schema
|
|
176
|
-
* @param schema - Optional schema definition for collection-time field lookups
|
|
177
|
-
*/
|
|
178
|
-
export declare function roleEntityDef<TRoleMap extends Record<string, object>>(name: string, schema?: SchemaDefinition<Record<string, object>>): EntityDef<TRoleMap>;
|
|
1
|
+
export { type RelationType, type ScalarFieldDef, type HasOneRelationDef, type HasManyRelationDef, type FieldDef, type EntitySchemaDef, type SchemaDefinition, type InferModel, type InferEntityNames, type EntityDef, type InferEntityDef, type EnumFieldDef, scalar, enumScalar, hasOne, hasMany, defineSchema, entityDef, roleEntityDef, } from '@contember/bindx-client';
|
|
179
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,aAAa,GACb,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Class for collecting field selection metadata during collection phase
|
|
4
|
-
*/
|
|
5
|
-
export declare class SelectionMetaCollector implements SelectionMeta {
|
|
6
|
-
readonly fields: Map<string, SelectionFieldMeta>;
|
|
7
|
-
/**
|
|
8
|
-
* Add a field to the selection.
|
|
9
|
-
*
|
|
10
|
-
* For has-many fields with parameters (filter, orderBy, limit, offset),
|
|
11
|
-
* uses alias as the key to allow multiple instances of the same field
|
|
12
|
-
* with different parameters.
|
|
13
|
-
*/
|
|
14
|
-
addField(fieldMeta: SelectionFieldMeta): void;
|
|
15
|
-
/**
|
|
16
|
-
* Get all root-level fields (not nested)
|
|
17
|
-
*/
|
|
18
|
-
getRootFields(): SelectionFieldMeta[];
|
|
19
|
-
/**
|
|
20
|
-
* Convert to plain object for serialization
|
|
21
|
-
*/
|
|
22
|
-
toJSON(): SelectionMeta;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Merge two selections together
|
|
26
|
-
*/
|
|
27
|
-
export declare function mergeSelections(target: SelectionMeta, source: SelectionMeta): void;
|
|
28
|
-
/**
|
|
29
|
-
* Create empty selection metadata
|
|
30
|
-
*/
|
|
31
|
-
export declare function createEmptySelection(): SelectionMeta;
|
|
1
|
+
export { SelectionMetaCollector, mergeSelections, createEmptySelection } from '@contember/bindx-client';
|
|
32
2
|
//# sourceMappingURL=SelectionMetaCollector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionMetaCollector.d.ts","sourceRoot":"","sources":["../../src/selection/SelectionMetaCollector.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectionMetaCollector.d.ts","sourceRoot":"","sources":["../../src/selection/SelectionMetaCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,77 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* HasMany parameters for filtering, ordering, pagination
|
|
4
|
-
*/
|
|
5
|
-
export interface HasManyParams {
|
|
6
|
-
filter?: unknown;
|
|
7
|
-
orderBy?: unknown;
|
|
8
|
-
limit?: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
totalCount?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Tree-based selection scope for collecting field selections.
|
|
14
|
-
*
|
|
15
|
-
* Unlike the flat path-based SelectionMetaCollector, SelectionScope
|
|
16
|
-
* maintains a hierarchical tree structure that naturally represents
|
|
17
|
-
* nested entity selections.
|
|
18
|
-
*
|
|
19
|
-
* Key benefits:
|
|
20
|
-
* - Natural tree structure matches entity relationships
|
|
21
|
-
* - No path string manipulation or collision risks
|
|
22
|
-
* - Scope carries its context - no need for symbol passing
|
|
23
|
-
* - Simple merge: just combine tree nodes
|
|
24
|
-
*/
|
|
25
|
-
export declare class SelectionScope {
|
|
26
|
-
private parent;
|
|
27
|
-
private children;
|
|
28
|
-
private scalarFields;
|
|
29
|
-
private relationMeta;
|
|
30
|
-
/**
|
|
31
|
-
* Create or get a child scope for a relation field.
|
|
32
|
-
* Automatically removes the field from scalars if it was there.
|
|
33
|
-
* New child scopes always include 'id' as a minimum selection.
|
|
34
|
-
*/
|
|
35
|
-
child(fieldName: string): SelectionScope;
|
|
36
|
-
/**
|
|
37
|
-
* Add a scalar field to this scope.
|
|
38
|
-
* If the field is already a relation, this is a no-op.
|
|
39
|
-
*/
|
|
40
|
-
addScalar(fieldName: string): void;
|
|
41
|
-
/**
|
|
42
|
-
* Mark a relation field as array (hasMany).
|
|
43
|
-
*/
|
|
44
|
-
markAsArray(fieldName: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* Set hasMany parameters for a relation field.
|
|
47
|
-
*/
|
|
48
|
-
setHasManyParams(fieldName: string, params: HasManyParams): void;
|
|
49
|
-
/**
|
|
50
|
-
* Check if this scope has any fields (scalar or relation).
|
|
51
|
-
*/
|
|
52
|
-
hasFields(): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Merge another scope into this one.
|
|
55
|
-
* Scalar fields are added, relation children are recursively merged.
|
|
56
|
-
*/
|
|
57
|
-
merge(other: SelectionScope): void;
|
|
58
|
-
/**
|
|
59
|
-
* Merge fields from a SelectionMeta into this scope.
|
|
60
|
-
* Useful for integrating with existing fluent builder selections.
|
|
61
|
-
*/
|
|
62
|
-
mergeFromSelectionMeta(meta: SelectionMeta): void;
|
|
63
|
-
/**
|
|
64
|
-
* Convert this scope to SelectionMeta format for backwards compatibility.
|
|
65
|
-
* This allows the new SelectionScope to be used with existing query builders.
|
|
66
|
-
*
|
|
67
|
-
* For has-many fields with params, generates auto-alias to allow multiple
|
|
68
|
-
* HasMany components for the same field with different parameters.
|
|
69
|
-
*/
|
|
70
|
-
toSelectionMeta(): SelectionMeta;
|
|
71
|
-
/**
|
|
72
|
-
* Create a SelectionScope from an existing SelectionMeta.
|
|
73
|
-
* Useful for converting explicit selections to scope format.
|
|
74
|
-
*/
|
|
75
|
-
static fromSelectionMeta(meta: SelectionMeta): SelectionScope;
|
|
76
|
-
}
|
|
1
|
+
export { SelectionScope, type HasManyParams } from '@contember/bindx-client';
|
|
77
2
|
//# sourceMappingURL=SelectionScope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../src/selection/SelectionScope.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../src/selection/SelectionScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Query specification for a single field
|
|
4
|
-
*/
|
|
5
|
-
export interface QueryFieldSpec {
|
|
6
|
-
/** Name of the field as it appears in the output */
|
|
7
|
-
name: string;
|
|
8
|
-
/** Path to the field in the source entity */
|
|
9
|
-
sourcePath: string[];
|
|
10
|
-
/** For nested objects/entities */
|
|
11
|
-
nested?: QuerySpec;
|
|
12
|
-
/** Whether this is an array/collection */
|
|
13
|
-
isArray?: boolean;
|
|
14
|
-
/** For has-many: filter parameters */
|
|
15
|
-
filter?: unknown;
|
|
16
|
-
/** For has-many: ordering parameters */
|
|
17
|
-
orderBy?: unknown;
|
|
18
|
-
/** For has-many: limit */
|
|
19
|
-
limit?: number;
|
|
20
|
-
/** For has-many: offset */
|
|
21
|
-
offset?: number;
|
|
22
|
-
/** For has-many: request totalCount via paginateRelation */
|
|
23
|
-
totalCount?: boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Query specification for fetching data.
|
|
27
|
-
* Backend adapters use this to construct their queries.
|
|
28
|
-
*/
|
|
29
|
-
export interface QuerySpec {
|
|
30
|
-
/** List of fields to fetch */
|
|
31
|
-
fields: QueryFieldSpec[];
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Builds a QuerySpec from SelectionMeta.
|
|
35
|
-
* This is what gets passed to the backend adapter.
|
|
36
|
-
*
|
|
37
|
-
* @param meta - The selection metadata
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildQueryFromSelection(meta: SelectionMeta): QuerySpec;
|
|
40
|
-
/**
|
|
41
|
-
* Collects all unique paths that need to be fetched.
|
|
42
|
-
* Useful for debugging and optimization.
|
|
43
|
-
*/
|
|
44
|
-
export declare function collectPaths(meta: SelectionMeta, basePath?: string[]): string[][];
|
|
1
|
+
export { buildQueryFromSelection, collectPaths, type QuerySpec, type QueryFieldSpec } from '@contember/bindx-client';
|
|
45
2
|
//# sourceMappingURL=buildQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/selection/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/selection/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Creates a reusable fragment using the fluent builder API.
|
|
4
|
-
*
|
|
5
|
-
* This is a curried function - first call provides the model type,
|
|
6
|
-
* second call provides the definer function.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* // Define a fragment
|
|
11
|
-
* const AuthorFragment = createFragment<Author>()(e =>
|
|
12
|
-
* e.id().name().email()
|
|
13
|
-
* )
|
|
14
|
-
*
|
|
15
|
-
* // Use in useEntity
|
|
16
|
-
* const article = useEntity('Article', { id }, e =>
|
|
17
|
-
* e.title().author(AuthorFragment)
|
|
18
|
-
* )
|
|
19
|
-
*
|
|
20
|
-
* // Or compose fragments
|
|
21
|
-
* const ArticleFragment = createFragment<Article>()(e =>
|
|
22
|
-
* e.id().title()
|
|
23
|
-
* .author(AuthorFragment)
|
|
24
|
-
* .tags(TagFragment)
|
|
25
|
-
* )
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function createFragment<TModel>(): <TResult extends object>(definer: (builder: SelectionBuilder<TModel>) => SelectionBuilder<TModel, TResult, object>) => FluentFragment<TModel, TResult>;
|
|
1
|
+
export { createFragment } from '@contember/bindx-client';
|
|
29
2
|
//# sourceMappingURL=createFragment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFragment.d.ts","sourceRoot":"","sources":["../../src/selection/createFragment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createFragment.d.ts","sourceRoot":"","sources":["../../src/selection/createFragment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Creates a fluent selection builder for an entity type.
|
|
4
|
-
* Uses Proxy to intercept method calls and build selection metadata.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const builder = createSelectionBuilder<Article>()
|
|
9
|
-
* const result = builder.id().title().author(a => a.name())
|
|
10
|
-
* const meta = result[SELECTION_META]
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare function createSelectionBuilder<TEntity, TSelected extends object = object, THasManyParams extends object = object>(initialMeta?: SelectionMeta): SelectionBuilder<TEntity, TSelected, THasManyParams>;
|
|
14
|
-
/**
|
|
15
|
-
* Extracts SelectionMeta from a builder
|
|
16
|
-
*/
|
|
17
|
-
export declare function getSelectionMeta(builder: SelectionBuilder<unknown, object, object>): SelectionMeta;
|
|
1
|
+
export { createSelectionBuilder, getSelectionMeta } from '@contember/bindx-client';
|
|
18
2
|
//# sourceMappingURL=createSelectionBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSelectionBuilder.d.ts","sourceRoot":"","sources":["../../src/selection/createSelectionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createSelectionBuilder.d.ts","sourceRoot":"","sources":["../../src/selection/createSelectionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,84 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Typed query parameter types for filter, orderBy, etc.
|
|
3
|
-
*
|
|
4
|
-
* Uses Input.Condition and Input.OrderDirection from @contember/schema
|
|
5
|
-
* for scalar conditions, wrapped in entity-aware types that work with
|
|
6
|
-
* plain TypeScript interfaces.
|
|
7
|
-
*/
|
|
8
|
-
import { Input } from '@contember/schema';
|
|
9
|
-
/**
|
|
10
|
-
* Condition operators for scalar values - re-exported from @contember/schema
|
|
11
|
-
*/
|
|
12
|
-
export type ScalarCondition<T> = Input.Condition<T>;
|
|
13
|
-
/**
|
|
14
|
-
* Order direction enum values - string literal union from Contember enum
|
|
15
|
-
*/
|
|
16
|
-
export type OrderDirection = `${Input.OrderDirection}`;
|
|
17
|
-
/**
|
|
18
|
-
* Base composed where with AND/OR/NOT logic
|
|
19
|
-
*/
|
|
20
|
-
export interface ComposedWhere<TEntity> {
|
|
21
|
-
readonly and?: readonly EntityWhere<TEntity>[];
|
|
22
|
-
readonly or?: readonly EntityWhere<TEntity>[];
|
|
23
|
-
readonly not?: EntityWhere<TEntity>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Checks if a type is a "plain object" (entity) vs a scalar like Date
|
|
27
|
-
* Date and other built-in objects are not treated as relations
|
|
28
|
-
*/
|
|
29
|
-
type IsPlainObject<T> = T extends Date ? false : T extends Array<any> ? false : T extends Function ? false : T extends object ? true : false;
|
|
30
|
-
/**
|
|
31
|
-
* Field-level where clause for an entity
|
|
32
|
-
* Maps each field to its appropriate condition type using Input.Condition
|
|
33
|
-
*/
|
|
34
|
-
export type FieldsWhere<TEntity> = {
|
|
35
|
-
readonly [K in keyof TEntity]?: NonNullable<TEntity[K]> extends Array<infer U> ? IsPlainObject<U> extends true ? EntityWhere<U> | null : Input.Condition<NonNullable<TEntity[K]>> | null : IsPlainObject<NonNullable<TEntity[K]>> extends true ? EntityWhere<NonNullable<TEntity[K]>> | null : Input.Condition<NonNullable<TEntity[K]>> | null;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Full where type for an entity - combines composed and field conditions
|
|
39
|
-
*/
|
|
40
|
-
export type EntityWhere<TEntity> = ComposedWhere<TEntity> & FieldsWhere<TEntity>;
|
|
41
|
-
/**
|
|
42
|
-
* Order by clause for an entity
|
|
43
|
-
* Each scalar field can have a direction, relations can have nested ordering
|
|
44
|
-
*/
|
|
45
|
-
export type EntityOrderBy<TEntity> = {
|
|
46
|
-
readonly [K in keyof TEntity]?: NonNullable<TEntity[K]> extends Array<any> ? never : IsPlainObject<NonNullable<TEntity[K]>> extends true ? EntityOrderBy<NonNullable<TEntity[K]>> | null : OrderDirection | null;
|
|
47
|
-
} & {
|
|
48
|
-
readonly _random?: boolean;
|
|
49
|
-
readonly _randomSeeded?: number;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Options for has-many relation selection with typed filter/orderBy
|
|
53
|
-
*
|
|
54
|
-
* @typeParam TItem - The related entity type (array item type)
|
|
55
|
-
* @typeParam TAlias - Optional alias for the field
|
|
56
|
-
*/
|
|
57
|
-
export interface TypedHasManyOptions<TItem, TAlias extends string = string> {
|
|
58
|
-
readonly as?: TAlias;
|
|
59
|
-
readonly filter?: EntityWhere<TItem>;
|
|
60
|
-
readonly orderBy?: readonly EntityOrderBy<TItem>[];
|
|
61
|
-
readonly limit?: number;
|
|
62
|
-
readonly offset?: number;
|
|
63
|
-
readonly totalCount?: boolean;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Alias-only options (for scalar or has-one with alias)
|
|
67
|
-
*/
|
|
68
|
-
export interface AliasOptions<TAlias extends string = string> {
|
|
69
|
-
readonly as?: TAlias;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Extracts the item type from an array type
|
|
73
|
-
*/
|
|
74
|
-
export type ArrayItemType<T> = T extends Array<infer U> ? U : never;
|
|
75
|
-
/**
|
|
76
|
-
* Checks if a type is an array
|
|
77
|
-
*/
|
|
78
|
-
export type IsArray<T> = T extends Array<any> ? true : false;
|
|
79
|
-
/**
|
|
80
|
-
* Extracts non-nullable type
|
|
81
|
-
*/
|
|
82
|
-
export type NonNullableType<T> = Exclude<T, null | undefined>;
|
|
83
|
-
export {};
|
|
1
|
+
export { type EntityWhere, type EntityOrderBy, type ScalarCondition, type OrderDirection, type TypedHasManyOptions, type AliasOptions, } from '@contember/bindx-client';
|
|
84
2
|
//# sourceMappingURL=queryTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryTypes.d.ts","sourceRoot":"","sources":["../../src/selection/queryTypes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"queryTypes.d.ts","sourceRoot":"","sources":["../../src/selection/queryTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GACjB,MAAM,yBAAyB,CAAA"}
|