@danielhritcu/zenstack-orm 3.5.6 → 3.5.7
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.cjs +118 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +118 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -689,6 +689,10 @@ type ClientOptions<Schema extends SchemaDef> = QueryOptions<Schema> & {
|
|
|
689
689
|
* for request-scoped values.
|
|
690
690
|
*/
|
|
691
691
|
where?: DefaultWhereConfig | (() => DefaultWhereConfig);
|
|
692
|
+
/**
|
|
693
|
+
* Default page size for .paginate() calls. Defaults to 20 if not set.
|
|
694
|
+
*/
|
|
695
|
+
pageSize?: number;
|
|
692
696
|
};
|
|
693
697
|
/**
|
|
694
698
|
* Kysely dialect.
|
|
@@ -1185,7 +1189,7 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Optio
|
|
|
1185
1189
|
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: FieldFilter<Schema, Model, Key, Options, WithAggregations>;
|
|
1186
1190
|
} & {
|
|
1187
1191
|
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
1188
|
-
search?: SearchPayload;
|
|
1192
|
+
search?: string | SearchPayload;
|
|
1189
1193
|
} & {
|
|
1190
1194
|
AND?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1191
1195
|
OR?: WhereInput<Schema, Model, Options, ScalarOnly>[];
|
|
@@ -3371,6 +3375,47 @@ declare namespace queryUtils {
|
|
|
3371
3375
|
export { queryUtils_TEMP_ALIAS_PREFIX as TEMP_ALIAS_PREFIX, queryUtils_aggregate as aggregate, queryUtils_buildJoinPairs as buildJoinPairs, queryUtils_ensureArray as ensureArray, queryUtils_extractFieldName as extractFieldName, queryUtils_extractIdFields as extractIdFields, queryUtils_extractModelName as extractModelName, queryUtils_fieldHasDefaultValue as fieldHasDefaultValue, queryUtils_flattenCompoundUniqueFilters as flattenCompoundUniqueFilters, queryUtils_getDelegateDescendantModels as getDelegateDescendantModels, queryUtils_getDiscriminatorField as getDiscriminatorField, queryUtils_getEnum as getEnum, queryUtils_getField as getField, queryUtils_getIdFields as getIdFields, queryUtils_getIdValues as getIdValues, queryUtils_getManyToManyRelation as getManyToManyRelation, queryUtils_getModel as getModel, queryUtils_getModelFields as getModelFields, queryUtils_getRelationForeignKeyFieldPairs as getRelationForeignKeyFieldPairs, queryUtils_getTypeDef as getTypeDef, queryUtils_getUniqueFields as getUniqueFields, queryUtils_hasModel as hasModel, queryUtils_isEnum as isEnum, queryUtils_isForeignKeyField as isForeignKeyField, queryUtils_isInheritedField as isInheritedField, queryUtils_isRelationField as isRelationField, queryUtils_isScalarField as isScalarField, queryUtils_isTypeDef as isTypeDef, queryUtils_isUnsupportedField as isUnsupportedField, queryUtils_makeDefaultOrderBy as makeDefaultOrderBy, queryUtils_requireField as requireField, queryUtils_requireIdFields as requireIdFields, queryUtils_requireModel as requireModel, queryUtils_requireTypeDef as requireTypeDef, queryUtils_stripAlias as stripAlias, queryUtils_tmpAlias as tmpAlias };
|
|
3372
3376
|
}
|
|
3373
3377
|
|
|
3378
|
+
/**
|
|
3379
|
+
* Offset pagination result.
|
|
3380
|
+
*/
|
|
3381
|
+
interface PaginatedOffset<T> {
|
|
3382
|
+
items: T[];
|
|
3383
|
+
pagination: {
|
|
3384
|
+
count: number;
|
|
3385
|
+
page: {
|
|
3386
|
+
size: number;
|
|
3387
|
+
current: number;
|
|
3388
|
+
next: number | null;
|
|
3389
|
+
prev: number | null;
|
|
3390
|
+
total: number;
|
|
3391
|
+
};
|
|
3392
|
+
has: {
|
|
3393
|
+
next: boolean;
|
|
3394
|
+
prev: boolean;
|
|
3395
|
+
};
|
|
3396
|
+
};
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Cursor pagination result.
|
|
3400
|
+
*/
|
|
3401
|
+
interface PaginatedCursor<T> {
|
|
3402
|
+
items: T[];
|
|
3403
|
+
pagination: {
|
|
3404
|
+
count: number;
|
|
3405
|
+
page: {
|
|
3406
|
+
size: number;
|
|
3407
|
+
};
|
|
3408
|
+
has: {
|
|
3409
|
+
next: boolean;
|
|
3410
|
+
prev: boolean;
|
|
3411
|
+
};
|
|
3412
|
+
cursor: {
|
|
3413
|
+
next: string | null;
|
|
3414
|
+
prev: string | null;
|
|
3415
|
+
};
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3374
3419
|
type VisitResult = void | {
|
|
3375
3420
|
abort: true;
|
|
3376
3421
|
};
|
|
@@ -3406,4 +3451,4 @@ declare namespace schemaUtils {
|
|
|
3406
3451
|
export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
|
|
3407
3452
|
}
|
|
3408
3453
|
|
|
3409
|
-
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DefaultWhereConfig, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type ExtResultBase, type ExtResultInferenceArgs, type ExtResultSelectOmitFields, type ExtractExtResult, type FilterKind, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetAllIncludedOperations, type GetIncludedOperations, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GetQueryOptions, type GetSlicedFilterKindsForField, type GetSlicedModels, type GetSlicedOperations, type GetSlicedProcedures, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, LOGICAL_COMBINATORS, type MapModelFieldType, type ModelAllowsCreate, type ModelHasRequiredUnsupportedField, type ModelOperations, type ModelResult, type ModelSlicingOptions, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsRequiringCreate, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SearchFieldMap, type SearchMode, type SearchPayload, type SearchStrategy, type SelectAwareExtResult, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SlicingOptions, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, ZENSTACK_QUERY_KIND_SYMBOL, ZENSTACK_QUERY_SYMBOL, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZenStackQueryKind, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
|
3454
|
+
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DefaultWhereConfig, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type ExtResultBase, type ExtResultInferenceArgs, type ExtResultSelectOmitFields, type ExtractExtResult, type FilterKind, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetAllIncludedOperations, type GetIncludedOperations, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GetQueryOptions, type GetSlicedFilterKindsForField, type GetSlicedModels, type GetSlicedOperations, type GetSlicedProcedures, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, LOGICAL_COMBINATORS, type MapModelFieldType, type ModelAllowsCreate, type ModelHasRequiredUnsupportedField, type ModelOperations, type ModelResult, type ModelSlicingOptions, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsRequiringCreate, type OrderBy, type PaginatedCursor, type PaginatedOffset, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SearchFieldMap, type SearchMode, type SearchPayload, type SearchStrategy, type SelectAwareExtResult, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SlicingOptions, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, ZENSTACK_QUERY_KIND_SYMBOL, ZENSTACK_QUERY_SYMBOL, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZenStackQueryKind, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
package/dist/index.d.ts
CHANGED
|
@@ -689,6 +689,10 @@ type ClientOptions<Schema extends SchemaDef> = QueryOptions<Schema> & {
|
|
|
689
689
|
* for request-scoped values.
|
|
690
690
|
*/
|
|
691
691
|
where?: DefaultWhereConfig | (() => DefaultWhereConfig);
|
|
692
|
+
/**
|
|
693
|
+
* Default page size for .paginate() calls. Defaults to 20 if not set.
|
|
694
|
+
*/
|
|
695
|
+
pageSize?: number;
|
|
692
696
|
};
|
|
693
697
|
/**
|
|
694
698
|
* Kysely dialect.
|
|
@@ -1185,7 +1189,7 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Optio
|
|
|
1185
1189
|
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: FieldFilter<Schema, Model, Key, Options, WithAggregations>;
|
|
1186
1190
|
} & {
|
|
1187
1191
|
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
1188
|
-
search?: SearchPayload;
|
|
1192
|
+
search?: string | SearchPayload;
|
|
1189
1193
|
} & {
|
|
1190
1194
|
AND?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1191
1195
|
OR?: WhereInput<Schema, Model, Options, ScalarOnly>[];
|
|
@@ -3371,6 +3375,47 @@ declare namespace queryUtils {
|
|
|
3371
3375
|
export { queryUtils_TEMP_ALIAS_PREFIX as TEMP_ALIAS_PREFIX, queryUtils_aggregate as aggregate, queryUtils_buildJoinPairs as buildJoinPairs, queryUtils_ensureArray as ensureArray, queryUtils_extractFieldName as extractFieldName, queryUtils_extractIdFields as extractIdFields, queryUtils_extractModelName as extractModelName, queryUtils_fieldHasDefaultValue as fieldHasDefaultValue, queryUtils_flattenCompoundUniqueFilters as flattenCompoundUniqueFilters, queryUtils_getDelegateDescendantModels as getDelegateDescendantModels, queryUtils_getDiscriminatorField as getDiscriminatorField, queryUtils_getEnum as getEnum, queryUtils_getField as getField, queryUtils_getIdFields as getIdFields, queryUtils_getIdValues as getIdValues, queryUtils_getManyToManyRelation as getManyToManyRelation, queryUtils_getModel as getModel, queryUtils_getModelFields as getModelFields, queryUtils_getRelationForeignKeyFieldPairs as getRelationForeignKeyFieldPairs, queryUtils_getTypeDef as getTypeDef, queryUtils_getUniqueFields as getUniqueFields, queryUtils_hasModel as hasModel, queryUtils_isEnum as isEnum, queryUtils_isForeignKeyField as isForeignKeyField, queryUtils_isInheritedField as isInheritedField, queryUtils_isRelationField as isRelationField, queryUtils_isScalarField as isScalarField, queryUtils_isTypeDef as isTypeDef, queryUtils_isUnsupportedField as isUnsupportedField, queryUtils_makeDefaultOrderBy as makeDefaultOrderBy, queryUtils_requireField as requireField, queryUtils_requireIdFields as requireIdFields, queryUtils_requireModel as requireModel, queryUtils_requireTypeDef as requireTypeDef, queryUtils_stripAlias as stripAlias, queryUtils_tmpAlias as tmpAlias };
|
|
3372
3376
|
}
|
|
3373
3377
|
|
|
3378
|
+
/**
|
|
3379
|
+
* Offset pagination result.
|
|
3380
|
+
*/
|
|
3381
|
+
interface PaginatedOffset<T> {
|
|
3382
|
+
items: T[];
|
|
3383
|
+
pagination: {
|
|
3384
|
+
count: number;
|
|
3385
|
+
page: {
|
|
3386
|
+
size: number;
|
|
3387
|
+
current: number;
|
|
3388
|
+
next: number | null;
|
|
3389
|
+
prev: number | null;
|
|
3390
|
+
total: number;
|
|
3391
|
+
};
|
|
3392
|
+
has: {
|
|
3393
|
+
next: boolean;
|
|
3394
|
+
prev: boolean;
|
|
3395
|
+
};
|
|
3396
|
+
};
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Cursor pagination result.
|
|
3400
|
+
*/
|
|
3401
|
+
interface PaginatedCursor<T> {
|
|
3402
|
+
items: T[];
|
|
3403
|
+
pagination: {
|
|
3404
|
+
count: number;
|
|
3405
|
+
page: {
|
|
3406
|
+
size: number;
|
|
3407
|
+
};
|
|
3408
|
+
has: {
|
|
3409
|
+
next: boolean;
|
|
3410
|
+
prev: boolean;
|
|
3411
|
+
};
|
|
3412
|
+
cursor: {
|
|
3413
|
+
next: string | null;
|
|
3414
|
+
prev: string | null;
|
|
3415
|
+
};
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3374
3419
|
type VisitResult = void | {
|
|
3375
3420
|
abort: true;
|
|
3376
3421
|
};
|
|
@@ -3406,4 +3451,4 @@ declare namespace schemaUtils {
|
|
|
3406
3451
|
export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
|
|
3407
3452
|
}
|
|
3408
3453
|
|
|
3409
|
-
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DefaultWhereConfig, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type ExtResultBase, type ExtResultInferenceArgs, type ExtResultSelectOmitFields, type ExtractExtResult, type FilterKind, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetAllIncludedOperations, type GetIncludedOperations, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GetQueryOptions, type GetSlicedFilterKindsForField, type GetSlicedModels, type GetSlicedOperations, type GetSlicedProcedures, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, LOGICAL_COMBINATORS, type MapModelFieldType, type ModelAllowsCreate, type ModelHasRequiredUnsupportedField, type ModelOperations, type ModelResult, type ModelSlicingOptions, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsRequiringCreate, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SearchFieldMap, type SearchMode, type SearchPayload, type SearchStrategy, type SelectAwareExtResult, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SlicingOptions, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, ZENSTACK_QUERY_KIND_SYMBOL, ZENSTACK_QUERY_SYMBOL, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZenStackQueryKind, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
|
3454
|
+
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DefaultWhereConfig, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type ExtResultBase, type ExtResultInferenceArgs, type ExtResultSelectOmitFields, type ExtractExtResult, type FilterKind, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetAllIncludedOperations, type GetIncludedOperations, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GetQueryOptions, type GetSlicedFilterKindsForField, type GetSlicedModels, type GetSlicedOperations, type GetSlicedProcedures, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, LOGICAL_COMBINATORS, type MapModelFieldType, type ModelAllowsCreate, type ModelHasRequiredUnsupportedField, type ModelOperations, type ModelResult, type ModelSlicingOptions, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsRequiringCreate, type OrderBy, type PaginatedCursor, type PaginatedOffset, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SearchFieldMap, type SearchMode, type SearchPayload, type SearchStrategy, type SelectAwareExtResult, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SlicingOptions, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, ZENSTACK_QUERY_KIND_SYMBOL, ZENSTACK_QUERY_SYMBOL, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZenStackQueryKind, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
package/dist/index.js
CHANGED
|
@@ -2825,9 +2825,18 @@ function extractSearch(where) {
|
|
|
2825
2825
|
let found;
|
|
2826
2826
|
const cleaned = {};
|
|
2827
2827
|
for (const [key, value] of Object.entries(obj)) {
|
|
2828
|
-
if (key === "search"
|
|
2829
|
-
|
|
2830
|
-
|
|
2828
|
+
if (key === "search") {
|
|
2829
|
+
if (typeof value === "string") {
|
|
2830
|
+
found = {
|
|
2831
|
+
q: value,
|
|
2832
|
+
profile: "default"
|
|
2833
|
+
};
|
|
2834
|
+
continue;
|
|
2835
|
+
}
|
|
2836
|
+
if (isSearchPayload(value)) {
|
|
2837
|
+
found = value;
|
|
2838
|
+
continue;
|
|
2839
|
+
}
|
|
2831
2840
|
}
|
|
2832
2841
|
if (key === "AND" || key === "OR") {
|
|
2833
2842
|
const result = extractSearch(value);
|
|
@@ -2959,9 +2968,9 @@ function expandSearch(model, where, searchDefaults, schemaModels, virtualRelatio
|
|
|
2959
2968
|
};
|
|
2960
2969
|
const profile = search2.profile ? searchDefaults?.[model]?.[search2.profile] : void 0;
|
|
2961
2970
|
const fields = search2.fields ?? profile?.fields;
|
|
2962
|
-
if (!fields)
|
|
2963
|
-
|
|
2964
|
-
}
|
|
2971
|
+
if (!fields) {
|
|
2972
|
+
throw new Error(`Search on "${model}" requires a "default" search profile or explicit fields.`);
|
|
2973
|
+
}
|
|
2965
2974
|
const mode = search2.mode ?? profile?.mode ?? "contains";
|
|
2966
2975
|
const strategy = search2.strategy ?? profile?.strategy ?? "all";
|
|
2967
2976
|
const tokens = unique(search2.q.trim().split(/\s+/).map((t) => t.toLowerCase()).filter(Boolean));
|
|
@@ -5790,7 +5799,28 @@ var ZodSchemaFactory = class {
|
|
|
5790
5799
|
}).optional();
|
|
5791
5800
|
const searchDefaults = this.schema.plugins?.searchDefaults?.[model];
|
|
5792
5801
|
if (searchDefaults) {
|
|
5793
|
-
|
|
5802
|
+
const searchFieldMapSchema = z.lazy(() => z.record(z.string(), z.union([
|
|
5803
|
+
z.literal(true),
|
|
5804
|
+
searchFieldMapSchema
|
|
5805
|
+
])));
|
|
5806
|
+
const searchPayloadSchema = zLooseObject({
|
|
5807
|
+
q: z.string(),
|
|
5808
|
+
fields: searchFieldMapSchema.optional(),
|
|
5809
|
+
profile: z.string().optional(),
|
|
5810
|
+
mode: z.enum([
|
|
5811
|
+
"contains",
|
|
5812
|
+
"startsWith",
|
|
5813
|
+
"equals"
|
|
5814
|
+
]).optional(),
|
|
5815
|
+
strategy: z.enum([
|
|
5816
|
+
"all",
|
|
5817
|
+
"any"
|
|
5818
|
+
]).optional()
|
|
5819
|
+
});
|
|
5820
|
+
fields["search"] = z.union([
|
|
5821
|
+
z.string(),
|
|
5822
|
+
searchPayloadSchema
|
|
5823
|
+
]).optional();
|
|
5794
5824
|
}
|
|
5795
5825
|
fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
5796
5826
|
fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
@@ -10126,7 +10156,87 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
10126
10156
|
}, "groupBy"),
|
|
10127
10157
|
exists: /* @__PURE__ */ __name((args) => {
|
|
10128
10158
|
return createPromise("exists", "exists", args, new ExistsOperationHandler(client, model, inputValidator), false);
|
|
10129
|
-
}, "exists")
|
|
10159
|
+
}, "exists"),
|
|
10160
|
+
paginate: /* @__PURE__ */ __name((args) => {
|
|
10161
|
+
return createZenStackPromise(async () => {
|
|
10162
|
+
const rawArgs = args ?? {};
|
|
10163
|
+
const pageSize = rawArgs["pageSize"] ?? client.$options?.default?.pageSize ?? 20;
|
|
10164
|
+
const page = rawArgs["page"];
|
|
10165
|
+
const cursorId = rawArgs["cursor"];
|
|
10166
|
+
const findBaseArgs = {};
|
|
10167
|
+
for (const [k, v] of Object.entries(rawArgs)) {
|
|
10168
|
+
if (k !== "page" && k !== "cursor" && k !== "pageSize") {
|
|
10169
|
+
findBaseArgs[k] = v;
|
|
10170
|
+
}
|
|
10171
|
+
}
|
|
10172
|
+
const countResult = await operations.count({
|
|
10173
|
+
where: findBaseArgs["where"]
|
|
10174
|
+
});
|
|
10175
|
+
let items;
|
|
10176
|
+
if (page !== void 0) {
|
|
10177
|
+
items = await operations.findMany({
|
|
10178
|
+
...findBaseArgs,
|
|
10179
|
+
skip: (page - 1) * pageSize,
|
|
10180
|
+
take: pageSize
|
|
10181
|
+
});
|
|
10182
|
+
} else {
|
|
10183
|
+
items = await operations.findMany({
|
|
10184
|
+
...findBaseArgs,
|
|
10185
|
+
...cursorId ? {
|
|
10186
|
+
cursor: {
|
|
10187
|
+
id: cursorId
|
|
10188
|
+
},
|
|
10189
|
+
skip: 1
|
|
10190
|
+
} : {},
|
|
10191
|
+
take: pageSize + 1
|
|
10192
|
+
});
|
|
10193
|
+
}
|
|
10194
|
+
const count = countResult;
|
|
10195
|
+
if (page !== void 0) {
|
|
10196
|
+
const total = Math.ceil(count / pageSize);
|
|
10197
|
+
const hasNext = page < total;
|
|
10198
|
+
const hasPrev = page > 1;
|
|
10199
|
+
return {
|
|
10200
|
+
items,
|
|
10201
|
+
pagination: {
|
|
10202
|
+
count,
|
|
10203
|
+
page: {
|
|
10204
|
+
size: pageSize,
|
|
10205
|
+
current: page,
|
|
10206
|
+
next: hasNext ? page + 1 : null,
|
|
10207
|
+
prev: hasPrev ? page - 1 : null,
|
|
10208
|
+
total
|
|
10209
|
+
},
|
|
10210
|
+
has: {
|
|
10211
|
+
next: hasNext,
|
|
10212
|
+
prev: hasPrev
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
};
|
|
10216
|
+
} else {
|
|
10217
|
+
const hasNext = items.length > pageSize;
|
|
10218
|
+
if (hasNext) items = items.slice(0, pageSize);
|
|
10219
|
+
const hasPrev = cursorId != null;
|
|
10220
|
+
return {
|
|
10221
|
+
items,
|
|
10222
|
+
pagination: {
|
|
10223
|
+
count,
|
|
10224
|
+
page: {
|
|
10225
|
+
size: pageSize
|
|
10226
|
+
},
|
|
10227
|
+
has: {
|
|
10228
|
+
next: hasNext,
|
|
10229
|
+
prev: hasPrev
|
|
10230
|
+
},
|
|
10231
|
+
cursor: {
|
|
10232
|
+
next: hasNext && items.length > 0 ? items[items.length - 1].id : null,
|
|
10233
|
+
prev: hasPrev && items.length > 0 ? items[0].id : null
|
|
10234
|
+
}
|
|
10235
|
+
}
|
|
10236
|
+
};
|
|
10237
|
+
}
|
|
10238
|
+
});
|
|
10239
|
+
}, "paginate")
|
|
10130
10240
|
};
|
|
10131
10241
|
const slicing = client.$options.slicing;
|
|
10132
10242
|
if (slicing?.models) {
|