@contember/bindx 0.1.5 → 0.1.8

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.
Files changed (76) hide show
  1. package/dist/adapter/ContemberAdapter.d.ts +11 -14
  2. package/dist/adapter/ContemberAdapter.d.ts.map +1 -1
  3. package/dist/brand/ComponentBrand.d.ts +1 -24
  4. package/dist/brand/ComponentBrand.d.ts.map +1 -1
  5. package/dist/contember/index.d.ts +1 -2
  6. package/dist/contember/index.d.ts.map +1 -1
  7. package/dist/handles/EntityHandle.d.ts +18 -29
  8. package/dist/handles/EntityHandle.d.ts.map +1 -1
  9. package/dist/handles/FieldHandle.d.ts +5 -3
  10. package/dist/handles/FieldHandle.d.ts.map +1 -1
  11. package/dist/handles/HasManyListHandle.d.ts +4 -3
  12. package/dist/handles/HasManyListHandle.d.ts.map +1 -1
  13. package/dist/handles/HasOneHandle.d.ts +33 -36
  14. package/dist/handles/HasOneHandle.d.ts.map +1 -1
  15. package/dist/handles/PlaceholderHandle.d.ts +9 -19
  16. package/dist/handles/PlaceholderHandle.d.ts.map +1 -1
  17. package/dist/handles/proxyFactory.d.ts +9 -37
  18. package/dist/handles/proxyFactory.d.ts.map +1 -1
  19. package/dist/handles/types.d.ts +4 -0
  20. package/dist/handles/types.d.ts.map +1 -1
  21. package/dist/index.d.ts +3 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/persistence/ContemberSchemaMutationAdapter.d.ts +24 -1
  24. package/dist/persistence/ContemberSchemaMutationAdapter.d.ts.map +1 -1
  25. package/dist/schema/ContemberSchema.d.ts +1 -97
  26. package/dist/schema/ContemberSchema.d.ts.map +1 -1
  27. package/dist/schema/SchemaLoader.d.ts +1 -27
  28. package/dist/schema/SchemaLoader.d.ts.map +1 -1
  29. package/dist/schema/SchemaRegistry.d.ts +1 -94
  30. package/dist/schema/SchemaRegistry.d.ts.map +1 -1
  31. package/dist/schema/roles.d.ts +1 -61
  32. package/dist/schema/roles.d.ts.map +1 -1
  33. package/dist/schema/types.d.ts +1 -178
  34. package/dist/schema/types.d.ts.map +1 -1
  35. package/dist/selection/SelectionMetaCollector.d.ts +1 -31
  36. package/dist/selection/SelectionMetaCollector.d.ts.map +1 -1
  37. package/dist/selection/SelectionScope.d.ts +1 -76
  38. package/dist/selection/SelectionScope.d.ts.map +1 -1
  39. package/dist/selection/buildQuery.d.ts +1 -44
  40. package/dist/selection/buildQuery.d.ts.map +1 -1
  41. package/dist/selection/createFragment.d.ts +1 -28
  42. package/dist/selection/createFragment.d.ts.map +1 -1
  43. package/dist/selection/createSelectionBuilder.d.ts +1 -17
  44. package/dist/selection/createSelectionBuilder.d.ts.map +1 -1
  45. package/dist/selection/queryTypes.d.ts +1 -83
  46. package/dist/selection/queryTypes.d.ts.map +1 -1
  47. package/dist/selection/types.d.ts +1 -237
  48. package/dist/selection/types.d.ts.map +1 -1
  49. package/dist/utils/aliasGenerator.d.ts +1 -24
  50. package/dist/utils/aliasGenerator.d.ts.map +1 -1
  51. package/package.json +4 -4
  52. package/src/adapter/ContemberAdapter.ts +193 -123
  53. package/src/brand/ComponentBrand.ts +1 -28
  54. package/src/contember/index.ts +1 -8
  55. package/src/handles/EntityHandle.ts +131 -61
  56. package/src/handles/FieldHandle.ts +19 -3
  57. package/src/handles/HasManyListHandle.ts +15 -12
  58. package/src/handles/HasOneHandle.ts +98 -66
  59. package/src/handles/PlaceholderHandle.ts +26 -24
  60. package/src/handles/proxyFactory.ts +29 -128
  61. package/src/handles/types.ts +6 -0
  62. package/src/index.ts +22 -3
  63. package/src/persistence/ContemberSchemaMutationAdapter.ts +19 -1
  64. package/src/schema/ContemberSchema.ts +14 -132
  65. package/src/schema/SchemaLoader.ts +1 -93
  66. package/src/schema/SchemaRegistry.ts +1 -286
  67. package/src/schema/roles.ts +10 -83
  68. package/src/schema/types.ts +21 -238
  69. package/src/selection/SelectionMetaCollector.ts +1 -122
  70. package/src/selection/SelectionScope.ts +1 -208
  71. package/src/selection/buildQuery.ts +1 -134
  72. package/src/selection/createFragment.ts +1 -50
  73. package/src/selection/createSelectionBuilder.ts +1 -283
  74. package/src/selection/queryTypes.ts +8 -135
  75. package/src/selection/types.ts +13 -320
  76. package/src/utils/aliasGenerator.ts +1 -56
@@ -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;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE7D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACjE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAClE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IACjD,cAAc,GACd,YAAY,GACZ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MG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAE3J"}
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
- import type { SelectionMeta, SelectionFieldMeta } from './types.js';
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,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGnE;;GAEG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAC3D,QAAQ,CAAC,MAAM,kCAAwC;IAEvD;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI;IA+C7C;;OAEG;IACH,aAAa,IAAI,kBAAkB,EAAE;IAUrC;;OAEG;IACH,MAAM,IAAI,aAAa;CAKvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAyBlF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,aAAa,CAEpD"}
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
- import type { SelectionMeta } from './types.js';
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,KAAK,EAAE,aAAa,EAAsB,MAAM,YAAY,CAAA;AAGnE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAUD;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IAE1B,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,QAAQ,CAAyC;IAGzD,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,YAAY,CAAuC;IAE3D;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc;IAexC;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAMlC;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAOpC;;OAEG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAOhE;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAyBlC;;;OAGG;IACH,sBAAsB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAoBjD;;;;;;OAMG;IACH,eAAe,IAAI,aAAa;IAqChC;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,cAAc;CAK7D"}
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
- import type { SelectionMeta } from './types.js';
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,KAAK,EAAE,aAAa,EAAsB,MAAM,YAAY,CAAA;AAEnE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,6CAA6C;IAC7C,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,kCAAkC;IAClC,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4DAA4D;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB,8BAA8B;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAA;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAwBtE;AA2CD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,EAAE,CAqBrF"}
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
- import { type FluentFragment, type SelectionBuilder } from './types.js';
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":"AACA,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAAC,MAAM,MACnB,OAAO,SAAS,MAAM,EACtC,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,KACvF,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBlC"}
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
- import { type SelectionBuilder, type SelectionMeta } from './types.js';
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,EAGN,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAElB,MAAM,YAAY,CAAA;AAInB;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,SAAS,MAAM,GAAG,MAAM,EAAE,cAAc,SAAS,MAAM,GAAG,MAAM,EACxH,WAAW,GAAE,aAAqC,GAChD,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CA8BtD;AA+ND;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAElG"}
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;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAMzC;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AAEnD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE,CAAA;AAMtD;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,OAAO;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,CAAA;IAC9C,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,WAAW,CAAC,OAAO,CAAC,EAAE,CAAA;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CACnC;AAED;;;GAGG;AACH,KAAK,aAAa,CAAC,CAAC,IACnB,CAAC,SAAS,IAAI,GAAG,KAAK,GACtB,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,GAC5B,CAAC,SAAS,QAAQ,GAAG,KAAK,GAC1B,CAAC,SAAS,MAAM,GAAG,IAAI,GACvB,KAAK,CAAA;AAEN;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,IAAI;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAC7B,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAC3C,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GAC5B,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,GACrB,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,OAA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