@zenstackhq/orm 3.4.0-beta.3 → 3.4.0-beta.4
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 +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -503,7 +503,7 @@ declare class InputValidator<Schema extends SchemaDef> {
|
|
|
503
503
|
private get providerSupportsCaseSensitivity();
|
|
504
504
|
/**
|
|
505
505
|
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
506
|
-
* Respects the precedence: field
|
|
506
|
+
* Respects the precedence: model[field] > model.$all > $all[field] > $all.$all.
|
|
507
507
|
*/
|
|
508
508
|
private getEffectiveFilterKinds;
|
|
509
509
|
/**
|
|
@@ -830,7 +830,7 @@ type SlicingOptions<Schema extends SchemaDef> = {
|
|
|
830
830
|
* Model slicing options.
|
|
831
831
|
*/
|
|
832
832
|
models?: {
|
|
833
|
-
[Model in GetModels<Schema>]?: ModelSlicingOptions<Schema, Model>;
|
|
833
|
+
[Model in GetModels<Schema> as Uncapitalize<Model>]?: ModelSlicingOptions<Schema, Model>;
|
|
834
834
|
} & {
|
|
835
835
|
/**
|
|
836
836
|
* Slicing options that apply to all models. Model-specific options will override these general
|
|
@@ -995,9 +995,9 @@ type GetSlicedModels<Schema extends SchemaDef, Options extends QueryOptions<Sche
|
|
|
995
995
|
type GetSlicedOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = Options['slicing'] extends infer Slicing ? Slicing extends SlicingOptions<Schema> ? GetIncludedOperations<Slicing, Model> extends infer IO ? GetExcludedOperations<Slicing, Model> extends infer EO ? IO extends '_none_' ? never : IsNever<IO> extends false ? Exclude<IO, EO> : Exclude<AllCrudOperations, EO> : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
996
996
|
type GetIncludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
997
997
|
models: infer Config;
|
|
998
|
-
} ? Model extends keyof Config ? 'includedOperations' extends keyof Config[Model] ? Config[Model] extends {
|
|
998
|
+
} ? Uncapitalize<Model> extends keyof Config ? 'includedOperations' extends keyof Config[Uncapitalize<Model>] ? Config[Uncapitalize<Model>] extends {
|
|
999
999
|
includedOperations: readonly [];
|
|
1000
|
-
} ? '_none_' : Config[Model] extends {
|
|
1000
|
+
} ? '_none_' : Config[Uncapitalize<Model>] extends {
|
|
1001
1001
|
includedOperations: readonly (infer IO)[];
|
|
1002
1002
|
} ? IO : never : GetAllIncludedOperations<Slicing> : GetAllIncludedOperations<Slicing> : AllCrudOperations : AllCrudOperations;
|
|
1003
1003
|
type GetAllIncludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
@@ -1009,7 +1009,7 @@ type GetAllIncludedOperations<Slicing extends SlicingOptions<any>> = 'models' ex
|
|
|
1009
1009
|
} ? IO : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
1010
1010
|
type GetExcludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
1011
1011
|
models: infer Config;
|
|
1012
|
-
} ? Model extends keyof Config ? Config[Model] extends {
|
|
1012
|
+
} ? Uncapitalize<Model> extends keyof Config ? Config[Uncapitalize<Model>] extends {
|
|
1013
1013
|
excludedOperations: readonly (infer EO)[];
|
|
1014
1014
|
} ? EO : GetAllExcludedOperations<Slicing> : GetAllExcludedOperations<Slicing> : never : never;
|
|
1015
1015
|
type GetAllExcludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
@@ -1036,7 +1036,7 @@ type GetIncludedFilterKindsFromModelConfig<ModelConfig, Field extends string> =
|
|
|
1036
1036
|
} ? IFK : never : GetAllFieldsIncludedFilterKinds<FieldsConfig> : GetAllFieldsIncludedFilterKinds<FieldsConfig> : never : never;
|
|
1037
1037
|
type GetFieldIncludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1038
1038
|
models?: infer Config;
|
|
1039
|
-
} ? Model extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1039
|
+
} ? Uncapitalize<Model> extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config[Uncapitalize<Model>], Field> : '$all' extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1040
1040
|
type GetAllFieldsIncludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1041
1041
|
includedFilterKinds: readonly [];
|
|
1042
1042
|
} ? '_none_' : FieldsConfig['$all'] extends {
|
|
@@ -1047,7 +1047,7 @@ type GetExcludedFilterKindsFromModelConfig<ModelConfig, Field extends string> =
|
|
|
1047
1047
|
} ? EFK : GetAllFieldsExcludedFilterKinds<FieldsConfig> : GetAllFieldsExcludedFilterKinds<FieldsConfig> : never : never;
|
|
1048
1048
|
type GetFieldExcludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1049
1049
|
models?: infer Config;
|
|
1050
|
-
} ? Model extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1050
|
+
} ? Uncapitalize<Model> extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config[Uncapitalize<Model>], Field> : '$all' extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1051
1051
|
type GetAllFieldsExcludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1052
1052
|
excludedFilterKinds: readonly (infer EFK)[];
|
|
1053
1053
|
} ? EFK : never : never;
|
package/dist/index.d.ts
CHANGED
|
@@ -503,7 +503,7 @@ declare class InputValidator<Schema extends SchemaDef> {
|
|
|
503
503
|
private get providerSupportsCaseSensitivity();
|
|
504
504
|
/**
|
|
505
505
|
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
506
|
-
* Respects the precedence: field
|
|
506
|
+
* Respects the precedence: model[field] > model.$all > $all[field] > $all.$all.
|
|
507
507
|
*/
|
|
508
508
|
private getEffectiveFilterKinds;
|
|
509
509
|
/**
|
|
@@ -830,7 +830,7 @@ type SlicingOptions<Schema extends SchemaDef> = {
|
|
|
830
830
|
* Model slicing options.
|
|
831
831
|
*/
|
|
832
832
|
models?: {
|
|
833
|
-
[Model in GetModels<Schema>]?: ModelSlicingOptions<Schema, Model>;
|
|
833
|
+
[Model in GetModels<Schema> as Uncapitalize<Model>]?: ModelSlicingOptions<Schema, Model>;
|
|
834
834
|
} & {
|
|
835
835
|
/**
|
|
836
836
|
* Slicing options that apply to all models. Model-specific options will override these general
|
|
@@ -995,9 +995,9 @@ type GetSlicedModels<Schema extends SchemaDef, Options extends QueryOptions<Sche
|
|
|
995
995
|
type GetSlicedOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = Options['slicing'] extends infer Slicing ? Slicing extends SlicingOptions<Schema> ? GetIncludedOperations<Slicing, Model> extends infer IO ? GetExcludedOperations<Slicing, Model> extends infer EO ? IO extends '_none_' ? never : IsNever<IO> extends false ? Exclude<IO, EO> : Exclude<AllCrudOperations, EO> : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
996
996
|
type GetIncludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
997
997
|
models: infer Config;
|
|
998
|
-
} ? Model extends keyof Config ? 'includedOperations' extends keyof Config[Model] ? Config[Model] extends {
|
|
998
|
+
} ? Uncapitalize<Model> extends keyof Config ? 'includedOperations' extends keyof Config[Uncapitalize<Model>] ? Config[Uncapitalize<Model>] extends {
|
|
999
999
|
includedOperations: readonly [];
|
|
1000
|
-
} ? '_none_' : Config[Model] extends {
|
|
1000
|
+
} ? '_none_' : Config[Uncapitalize<Model>] extends {
|
|
1001
1001
|
includedOperations: readonly (infer IO)[];
|
|
1002
1002
|
} ? IO : never : GetAllIncludedOperations<Slicing> : GetAllIncludedOperations<Slicing> : AllCrudOperations : AllCrudOperations;
|
|
1003
1003
|
type GetAllIncludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
@@ -1009,7 +1009,7 @@ type GetAllIncludedOperations<Slicing extends SlicingOptions<any>> = 'models' ex
|
|
|
1009
1009
|
} ? IO : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
1010
1010
|
type GetExcludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
1011
1011
|
models: infer Config;
|
|
1012
|
-
} ? Model extends keyof Config ? Config[Model] extends {
|
|
1012
|
+
} ? Uncapitalize<Model> extends keyof Config ? Config[Uncapitalize<Model>] extends {
|
|
1013
1013
|
excludedOperations: readonly (infer EO)[];
|
|
1014
1014
|
} ? EO : GetAllExcludedOperations<Slicing> : GetAllExcludedOperations<Slicing> : never : never;
|
|
1015
1015
|
type GetAllExcludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
@@ -1036,7 +1036,7 @@ type GetIncludedFilterKindsFromModelConfig<ModelConfig, Field extends string> =
|
|
|
1036
1036
|
} ? IFK : never : GetAllFieldsIncludedFilterKinds<FieldsConfig> : GetAllFieldsIncludedFilterKinds<FieldsConfig> : never : never;
|
|
1037
1037
|
type GetFieldIncludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1038
1038
|
models?: infer Config;
|
|
1039
|
-
} ? Model extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1039
|
+
} ? Uncapitalize<Model> extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config[Uncapitalize<Model>], Field> : '$all' extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1040
1040
|
type GetAllFieldsIncludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1041
1041
|
includedFilterKinds: readonly [];
|
|
1042
1042
|
} ? '_none_' : FieldsConfig['$all'] extends {
|
|
@@ -1047,7 +1047,7 @@ type GetExcludedFilterKindsFromModelConfig<ModelConfig, Field extends string> =
|
|
|
1047
1047
|
} ? EFK : GetAllFieldsExcludedFilterKinds<FieldsConfig> : GetAllFieldsExcludedFilterKinds<FieldsConfig> : never : never;
|
|
1048
1048
|
type GetFieldExcludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1049
1049
|
models?: infer Config;
|
|
1050
|
-
} ? Model extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1050
|
+
} ? Uncapitalize<Model> extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config[Uncapitalize<Model>], Field> : '$all' extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1051
1051
|
type GetAllFieldsExcludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1052
1052
|
excludedFilterKinds: readonly (infer EFK)[];
|
|
1053
1053
|
} ? EFK : never : never;
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
19
|
|
|
20
20
|
// src/client/client-impl.ts
|
|
21
|
-
import { invariant as invariant14 } from "@zenstackhq/common-helpers";
|
|
21
|
+
import { invariant as invariant14, lowerCaseFirst as lowerCaseFirst3 } from "@zenstackhq/common-helpers";
|
|
22
22
|
import { CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor as DefaultQueryExecutor2, Kysely, Log, sql as sql8, Transaction } from "kysely";
|
|
23
23
|
|
|
24
24
|
// src/client/crud/operations/aggregate.ts
|
|
@@ -4591,7 +4591,7 @@ var UpdateOperationHandler = class extends BaseOperationHandler {
|
|
|
4591
4591
|
};
|
|
4592
4592
|
|
|
4593
4593
|
// src/client/crud/validator/index.ts
|
|
4594
|
-
import { enumerate as enumerate3, invariant as invariant9 } from "@zenstackhq/common-helpers";
|
|
4594
|
+
import { enumerate as enumerate3, invariant as invariant9, lowerCaseFirst } from "@zenstackhq/common-helpers";
|
|
4595
4595
|
import Decimal5 from "decimal.js";
|
|
4596
4596
|
import { match as match14, P as P3 } from "ts-pattern";
|
|
4597
4597
|
import { z as z2, ZodType } from "zod";
|
|
@@ -6387,7 +6387,7 @@ var InputValidator = class {
|
|
|
6387
6387
|
}
|
|
6388
6388
|
/**
|
|
6389
6389
|
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
6390
|
-
* Respects the precedence: field
|
|
6390
|
+
* Respects the precedence: model[field] > model.$all > $all[field] > $all.$all.
|
|
6391
6391
|
*/
|
|
6392
6392
|
getEffectiveFilterKinds(model, field) {
|
|
6393
6393
|
if (!model) {
|
|
@@ -6397,21 +6397,27 @@ var InputValidator = class {
|
|
|
6397
6397
|
if (!slicing?.models) {
|
|
6398
6398
|
return void 0;
|
|
6399
6399
|
}
|
|
6400
|
-
const
|
|
6400
|
+
const modelsRecord = slicing.models;
|
|
6401
|
+
const modelConfig = modelsRecord[lowerCaseFirst(model)];
|
|
6401
6402
|
if (modelConfig?.fields) {
|
|
6402
6403
|
const fieldConfig = modelConfig.fields[field];
|
|
6403
6404
|
if (fieldConfig) {
|
|
6404
6405
|
return this.computeFilterKinds(fieldConfig.includedFilterKinds, fieldConfig.excludedFilterKinds);
|
|
6405
6406
|
}
|
|
6406
|
-
const allFieldsConfig = modelConfig.fields
|
|
6407
|
+
const allFieldsConfig = modelConfig.fields["$all"];
|
|
6407
6408
|
if (allFieldsConfig) {
|
|
6408
6409
|
return this.computeFilterKinds(allFieldsConfig.includedFilterKinds, allFieldsConfig.excludedFilterKinds);
|
|
6409
6410
|
}
|
|
6410
6411
|
}
|
|
6411
|
-
const allModelsConfig =
|
|
6412
|
+
const allModelsConfig = modelsRecord["$all"];
|
|
6412
6413
|
if (allModelsConfig?.fields) {
|
|
6413
|
-
|
|
6414
|
-
|
|
6414
|
+
const allModelsFieldConfig = allModelsConfig.fields[field];
|
|
6415
|
+
if (allModelsFieldConfig) {
|
|
6416
|
+
return this.computeFilterKinds(allModelsFieldConfig.includedFilterKinds, allModelsFieldConfig.excludedFilterKinds);
|
|
6417
|
+
}
|
|
6418
|
+
const allModelsAllFieldsConfig = allModelsConfig.fields["$all"];
|
|
6419
|
+
if (allModelsAllFieldsConfig) {
|
|
6420
|
+
return this.computeFilterKinds(allModelsAllFieldsConfig.includedFilterKinds, allModelsAllFieldsConfig.excludedFilterKinds);
|
|
6415
6421
|
}
|
|
6416
6422
|
}
|
|
6417
6423
|
return void 0;
|
|
@@ -8141,7 +8147,7 @@ __export(functions_exports, {
|
|
|
8141
8147
|
search: () => search,
|
|
8142
8148
|
startsWith: () => startsWith
|
|
8143
8149
|
});
|
|
8144
|
-
import { invariant as invariant12, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
8150
|
+
import { invariant as invariant12, lowerCaseFirst as lowerCaseFirst2, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
8145
8151
|
import { sql as sql6, ValueNode as ValueNode3 } from "kysely";
|
|
8146
8152
|
import { match as match16 } from "ts-pattern";
|
|
8147
8153
|
var contains = /* @__PURE__ */ __name((eb, args, context) => textMatch(eb, args, context, "contains"), "contains");
|
|
@@ -8252,7 +8258,7 @@ var currentOperation = /* @__PURE__ */ __name((_eb, args, { operation }) => {
|
|
|
8252
8258
|
function processCasing(casing, result, model) {
|
|
8253
8259
|
const opNode = casing.toOperationNode();
|
|
8254
8260
|
invariant12(ValueNode3.is(opNode) && typeof opNode.value === "string", '"casting" parameter must be a string value');
|
|
8255
|
-
result = match16(opNode.value).with("original", () => model).with("upper", () => result.toUpperCase()).with("lower", () => result.toLowerCase()).with("capitalize", () => upperCaseFirst(result)).with("uncapitalize", () =>
|
|
8261
|
+
result = match16(opNode.value).with("original", () => model).with("upper", () => result.toUpperCase()).with("lower", () => result.toLowerCase()).with("capitalize", () => upperCaseFirst(result)).with("uncapitalize", () => lowerCaseFirst2(result)).otherwise(() => {
|
|
8256
8262
|
throw new Error(`Invalid casing value: ${opNode.value}. Must be "original", "upper", "lower", "capitalize", or "uncapitalize".`);
|
|
8257
8263
|
});
|
|
8258
8264
|
return result;
|
|
@@ -9208,7 +9214,7 @@ function createModelCrudHandler(client, model, inputValidator, resultProcessor)
|
|
|
9208
9214
|
};
|
|
9209
9215
|
const slicing = client.$options.slicing;
|
|
9210
9216
|
if (slicing?.models) {
|
|
9211
|
-
const modelSlicing = slicing.models[model];
|
|
9217
|
+
const modelSlicing = slicing.models[lowerCaseFirst3(model)];
|
|
9212
9218
|
const allSlicing = slicing.models.$all;
|
|
9213
9219
|
const includedOperations = modelSlicing?.includedOperations ?? allSlicing?.includedOperations;
|
|
9214
9220
|
const excludedOperations = modelSlicing?.excludedOperations ?? allSlicing?.excludedOperations;
|