@web-ts-toolkit/moo 0.42.2 → 0.47.1
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/README.md +122 -7
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +386 -57
- package/index.mjs +386 -57
- package/is.d.mts +2 -2
- package/is.d.ts +2 -2
- package/is.js +8 -7
- package/is.mjs +8 -7
- package/llms.txt +33 -5
- package/package.json +3 -3
- package/plugins/cascade-delete.d.mts +151 -4
- package/plugins/cascade-delete.d.ts +151 -4
- package/plugins/cascade-delete.js +354 -33
- package/plugins/cascade-delete.mjs +354 -33
- package/plugins/index.d.mts +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +354 -33
- package/plugins/index.mjs +354 -33
- package/plugins/keycloak-user-sync.d.mts +32 -4
- package/plugins/keycloak-user-sync.d.ts +32 -4
- package/plugins/keycloak-user-sync.js +208 -45
- package/plugins/keycloak-user-sync.mjs +208 -45
- package/plugins/model-function.d.mts +46 -0
- package/plugins/model-function.d.ts +46 -0
- package/plugins/new-document.d.mts +21 -2
- package/plugins/new-document.d.ts +21 -2
- package/schema.d.mts +34 -5
- package/schema.d.ts +34 -5
- package/schema.js +24 -17
- package/schema.mjs +24 -17
package/schema.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arbitrary Mongoose schema-type options merged over the helper defaults.
|
|
3
|
+
* Provided keys win over the defaults at runtime via object spread; the
|
|
4
|
+
* helpers type this with `Omit<Base, keyof TOverrides> & TOverrides` so an
|
|
5
|
+
* override of `default`, `trim`, or `index` is reflected in the inferred
|
|
6
|
+
* return type instead of keeping the fixed default type.
|
|
7
|
+
*/
|
|
1
8
|
type SchemaOptionOverrides = Record<string, unknown>;
|
|
2
|
-
|
|
9
|
+
type UniqueNullableBase = {
|
|
3
10
|
type: StringConstructor;
|
|
4
11
|
index: {
|
|
5
12
|
unique: boolean;
|
|
6
13
|
partialFilterExpression: {
|
|
7
|
-
[
|
|
14
|
+
[field: string]: {
|
|
8
15
|
$type: string;
|
|
9
16
|
};
|
|
10
17
|
};
|
|
@@ -12,12 +19,12 @@ declare const uniqueNullableString: (field: string, options?: SchemaOptionOverri
|
|
|
12
19
|
trim: boolean;
|
|
13
20
|
default: null;
|
|
14
21
|
};
|
|
15
|
-
|
|
22
|
+
type UniqueEmptiableBase = {
|
|
16
23
|
type: StringConstructor;
|
|
17
24
|
index: {
|
|
18
25
|
unique: boolean;
|
|
19
26
|
partialFilterExpression: {
|
|
20
|
-
[
|
|
27
|
+
[field: string]: {
|
|
21
28
|
$type: string;
|
|
22
29
|
$gt: string;
|
|
23
30
|
};
|
|
@@ -26,5 +33,27 @@ declare const uniqueEmptiableString: (field: string, options?: SchemaOptionOverr
|
|
|
26
33
|
trim: boolean;
|
|
27
34
|
default: null;
|
|
28
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Partial-unique string field that allows any number of `null` values while
|
|
38
|
+
* still rejecting duplicate non-null strings (including `''`). The partial
|
|
39
|
+
* index only covers string-typed values (`{ [field]: { $type: 'string' } }`),
|
|
40
|
+
* so `null`/missing entries never conflict. Extra `options` are spread over
|
|
41
|
+
* the defaults and reflected in the return type.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const userSchema = new Schema({ email: uniqueNullableString('email') });
|
|
45
|
+
*/
|
|
46
|
+
declare const uniqueNullableString: <TOverrides extends SchemaOptionOverrides = Record<string, never>>(field: string, options?: TOverrides) => Omit<UniqueNullableBase, keyof TOverrides> & TOverrides;
|
|
47
|
+
/**
|
|
48
|
+
* Partial-unique string field that additionally ignores empty strings:
|
|
49
|
+
* both `null` and `''` can repeat, while duplicate non-empty strings are
|
|
50
|
+
* rejected. The partial index only covers strings longer than `''`
|
|
51
|
+
* (`{ [field]: { $type: 'string', $gt: '' } }`). Extra `options` are spread
|
|
52
|
+
* over the defaults and reflected in the return type.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const userSchema = new Schema({ username: uniqueEmptiableString('username') });
|
|
56
|
+
*/
|
|
57
|
+
declare const uniqueEmptiableString: <TOverrides extends SchemaOptionOverrides = Record<string, never>>(field: string, options?: TOverrides) => Omit<UniqueEmptiableBase, keyof TOverrides> & TOverrides;
|
|
29
58
|
|
|
30
|
-
export { uniqueEmptiableString, uniqueNullableString };
|
|
59
|
+
export { type SchemaOptionOverrides, uniqueEmptiableString, uniqueNullableString };
|
package/schema.js
CHANGED
|
@@ -24,23 +24,30 @@ __export(schema_exports, {
|
|
|
24
24
|
uniqueNullableString: () => uniqueNullableString
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(schema_exports);
|
|
27
|
-
var uniqueNullableString = (field, options
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
var uniqueNullableString = (field, options) => (
|
|
28
|
+
// The runtime spread applies overrides over the defaults; the cast expresses
|
|
29
|
+
// that override-wins merge because TypeScript cannot narrow a generic spread.
|
|
30
|
+
{
|
|
31
|
+
type: String,
|
|
32
|
+
index: { unique: true, partialFilterExpression: { [field]: { $type: "string" } } },
|
|
33
|
+
trim: true,
|
|
34
|
+
default: null,
|
|
35
|
+
...options
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
var uniqueEmptiableString = (field, options) => (
|
|
39
|
+
// Same override-wins spread contract as uniqueNullableString above.
|
|
40
|
+
{
|
|
41
|
+
type: String,
|
|
42
|
+
index: {
|
|
43
|
+
unique: true,
|
|
44
|
+
partialFilterExpression: { [field]: { $type: "string", $gt: "" } }
|
|
45
|
+
},
|
|
46
|
+
trim: true,
|
|
47
|
+
default: null,
|
|
48
|
+
...options
|
|
49
|
+
}
|
|
50
|
+
);
|
|
44
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
52
|
0 && (module.exports = {
|
|
46
53
|
uniqueEmptiableString,
|
package/schema.mjs
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
// src/schema.ts
|
|
2
|
-
var uniqueNullableString = (field, options
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
var uniqueNullableString = (field, options) => (
|
|
3
|
+
// The runtime spread applies overrides over the defaults; the cast expresses
|
|
4
|
+
// that override-wins merge because TypeScript cannot narrow a generic spread.
|
|
5
|
+
{
|
|
6
|
+
type: String,
|
|
7
|
+
index: { unique: true, partialFilterExpression: { [field]: { $type: "string" } } },
|
|
8
|
+
trim: true,
|
|
9
|
+
default: null,
|
|
10
|
+
...options
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
var uniqueEmptiableString = (field, options) => (
|
|
14
|
+
// Same override-wins spread contract as uniqueNullableString above.
|
|
15
|
+
{
|
|
16
|
+
type: String,
|
|
17
|
+
index: {
|
|
18
|
+
unique: true,
|
|
19
|
+
partialFilterExpression: { [field]: { $type: "string", $gt: "" } }
|
|
20
|
+
},
|
|
21
|
+
trim: true,
|
|
22
|
+
default: null,
|
|
23
|
+
...options
|
|
24
|
+
}
|
|
25
|
+
);
|
|
19
26
|
export {
|
|
20
27
|
uniqueEmptiableString,
|
|
21
28
|
uniqueNullableString
|