pinia-orm-edge 1.7.3-28257628.bbb8bab
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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/casts.cjs +124 -0
- package/dist/casts.d.cts +66 -0
- package/dist/casts.d.mts +66 -0
- package/dist/casts.d.ts +66 -0
- package/dist/casts.mjs +118 -0
- package/dist/decorators.cjs +219 -0
- package/dist/decorators.d.cts +107 -0
- package/dist/decorators.d.mts +107 -0
- package/dist/decorators.d.ts +107 -0
- package/dist/decorators.mjs +198 -0
- package/dist/helpers.cjs +69 -0
- package/dist/helpers.d.cts +54 -0
- package/dist/helpers.d.mts +54 -0
- package/dist/helpers.d.ts +54 -0
- package/dist/helpers.mjs +61 -0
- package/dist/index.cjs +3592 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.mts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.mjs +3561 -0
- package/dist/nanoid/async.cjs +42 -0
- package/dist/nanoid/async.d.cts +29 -0
- package/dist/nanoid/async.d.mts +29 -0
- package/dist/nanoid/async.d.ts +29 -0
- package/dist/nanoid/async.mjs +39 -0
- package/dist/nanoid/index.cjs +42 -0
- package/dist/nanoid/index.d.cts +24 -0
- package/dist/nanoid/index.d.mts +24 -0
- package/dist/nanoid/index.d.ts +24 -0
- package/dist/nanoid/index.mjs +39 -0
- package/dist/nanoid/non-secure.cjs +42 -0
- package/dist/nanoid/non-secure.d.cts +24 -0
- package/dist/nanoid/non-secure.d.mts +24 -0
- package/dist/nanoid/non-secure.d.ts +24 -0
- package/dist/nanoid/non-secure.mjs +39 -0
- package/dist/shared/pinia-orm.1bd7d299.mjs +153 -0
- package/dist/shared/pinia-orm.4ff2e12f.mjs +66 -0
- package/dist/shared/pinia-orm.876a7cdc.d.cts +1981 -0
- package/dist/shared/pinia-orm.876a7cdc.d.mts +1981 -0
- package/dist/shared/pinia-orm.876a7cdc.d.ts +1981 -0
- package/dist/shared/pinia-orm.a62c4fc4.cjs +167 -0
- package/dist/shared/pinia-orm.a7e3e0f3.cjs +68 -0
- package/dist/uuid/v1.cjs +41 -0
- package/dist/uuid/v1.d.cts +25 -0
- package/dist/uuid/v1.d.mts +25 -0
- package/dist/uuid/v1.d.ts +25 -0
- package/dist/uuid/v1.mjs +38 -0
- package/dist/uuid/v4.cjs +41 -0
- package/dist/uuid/v4.d.cts +25 -0
- package/dist/uuid/v4.d.mts +25 -0
- package/dist/uuid/v4.d.ts +25 -0
- package/dist/uuid/v4.mjs +38 -0
- package/package.json +126 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const async = require('nanoid/async');
|
4
|
+
const CastAttribute = require('../shared/pinia-orm.a7e3e0f3.cjs');
|
5
|
+
|
6
|
+
var __defProp = Object.defineProperty;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __publicField = (obj, key, value) => {
|
9
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
10
|
+
return value;
|
11
|
+
};
|
12
|
+
class UidCast extends CastAttribute.CastAttribute {
|
13
|
+
/**
|
14
|
+
* Create a new String attribute instance.
|
15
|
+
*/
|
16
|
+
constructor(attributes) {
|
17
|
+
super(attributes);
|
18
|
+
}
|
19
|
+
static withParameters(parameters) {
|
20
|
+
this.parameters = parameters;
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Make the value for the attribute.
|
25
|
+
*/
|
26
|
+
async set(value) {
|
27
|
+
const nanoid = this.$parameters?.alphabet ? async.customAlphabet(this.$parameters.alphabet) : async.nanoid;
|
28
|
+
return value ?? await nanoid(this.$parameters?.size);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
__publicField(UidCast, "parameters");
|
32
|
+
|
33
|
+
function Uid(options) {
|
34
|
+
return (target, propertyKey) => {
|
35
|
+
const self = target.$self();
|
36
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
37
|
+
self.setRegistry(propertyKey, () => self.uid());
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.Uid = Uid;
|
42
|
+
exports.UidCast = UidCast;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.cjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Create a cast nanoid/async.
|
8
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
9
|
+
*/
|
10
|
+
declare class UidCast extends CastAttribute {
|
11
|
+
static parameters?: NanoidOptions;
|
12
|
+
/**
|
13
|
+
* Create a new String attribute instance.
|
14
|
+
*/
|
15
|
+
constructor(attributes: ModelFields);
|
16
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
17
|
+
/**
|
18
|
+
* Make the value for the attribute.
|
19
|
+
*/
|
20
|
+
set(value: any): Promise<string | null>;
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Creates an uuid based on nanoid/async.
|
25
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
26
|
+
*/
|
27
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
28
|
+
|
29
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.mjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Create a cast nanoid/async.
|
8
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
9
|
+
*/
|
10
|
+
declare class UidCast extends CastAttribute {
|
11
|
+
static parameters?: NanoidOptions;
|
12
|
+
/**
|
13
|
+
* Create a new String attribute instance.
|
14
|
+
*/
|
15
|
+
constructor(attributes: ModelFields);
|
16
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
17
|
+
/**
|
18
|
+
* Make the value for the attribute.
|
19
|
+
*/
|
20
|
+
set(value: any): Promise<string | null>;
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Creates an uuid based on nanoid/async.
|
25
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
26
|
+
*/
|
27
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
28
|
+
|
29
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.js';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Create a cast nanoid/async.
|
8
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
9
|
+
*/
|
10
|
+
declare class UidCast extends CastAttribute {
|
11
|
+
static parameters?: NanoidOptions;
|
12
|
+
/**
|
13
|
+
* Create a new String attribute instance.
|
14
|
+
*/
|
15
|
+
constructor(attributes: ModelFields);
|
16
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
17
|
+
/**
|
18
|
+
* Make the value for the attribute.
|
19
|
+
*/
|
20
|
+
set(value: any): Promise<string | null>;
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Creates an uuid based on nanoid/async.
|
25
|
+
* @deprecated will be removed in v2 because nanoid v5 dropped it
|
26
|
+
*/
|
27
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
28
|
+
|
29
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { customAlphabet, nanoid } from 'nanoid/async';
|
2
|
+
import { C as CastAttribute } from '../shared/pinia-orm.4ff2e12f.mjs';
|
3
|
+
|
4
|
+
var __defProp = Object.defineProperty;
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6
|
+
var __publicField = (obj, key, value) => {
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
8
|
+
return value;
|
9
|
+
};
|
10
|
+
class UidCast extends CastAttribute {
|
11
|
+
/**
|
12
|
+
* Create a new String attribute instance.
|
13
|
+
*/
|
14
|
+
constructor(attributes) {
|
15
|
+
super(attributes);
|
16
|
+
}
|
17
|
+
static withParameters(parameters) {
|
18
|
+
this.parameters = parameters;
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Make the value for the attribute.
|
23
|
+
*/
|
24
|
+
async set(value) {
|
25
|
+
const nanoid$1 = this.$parameters?.alphabet ? customAlphabet(this.$parameters.alphabet) : nanoid;
|
26
|
+
return value ?? await nanoid$1(this.$parameters?.size);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
__publicField(UidCast, "parameters");
|
30
|
+
|
31
|
+
function Uid(options) {
|
32
|
+
return (target, propertyKey) => {
|
33
|
+
const self = target.$self();
|
34
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
35
|
+
self.setRegistry(propertyKey, () => self.uid());
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,42 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const nanoid = require('nanoid');
|
4
|
+
const CastAttribute = require('../shared/pinia-orm.a7e3e0f3.cjs');
|
5
|
+
|
6
|
+
var __defProp = Object.defineProperty;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __publicField = (obj, key, value) => {
|
9
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
10
|
+
return value;
|
11
|
+
};
|
12
|
+
class UidCast extends CastAttribute.CastAttribute {
|
13
|
+
/**
|
14
|
+
* Create a new String attribute instance.
|
15
|
+
*/
|
16
|
+
constructor(attributes) {
|
17
|
+
super(attributes);
|
18
|
+
}
|
19
|
+
static withParameters(parameters) {
|
20
|
+
this.parameters = parameters;
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Make the value for the attribute.
|
25
|
+
*/
|
26
|
+
set(value) {
|
27
|
+
const nanoid$1 = this.$parameters?.alphabet ? nanoid.customAlphabet(this.$parameters.alphabet) : nanoid.nanoid;
|
28
|
+
return value ?? nanoid$1(this.$parameters?.size);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
__publicField(UidCast, "parameters");
|
32
|
+
|
33
|
+
function Uid(options) {
|
34
|
+
return (target, propertyKey) => {
|
35
|
+
const self = target.$self();
|
36
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
37
|
+
self.setRegistry(propertyKey, () => self.uid());
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.Uid = Uid;
|
42
|
+
exports.UidCast = UidCast;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.cjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.mjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.js';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { customAlphabet, nanoid } from 'nanoid';
|
2
|
+
import { C as CastAttribute } from '../shared/pinia-orm.4ff2e12f.mjs';
|
3
|
+
|
4
|
+
var __defProp = Object.defineProperty;
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6
|
+
var __publicField = (obj, key, value) => {
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
8
|
+
return value;
|
9
|
+
};
|
10
|
+
class UidCast extends CastAttribute {
|
11
|
+
/**
|
12
|
+
* Create a new String attribute instance.
|
13
|
+
*/
|
14
|
+
constructor(attributes) {
|
15
|
+
super(attributes);
|
16
|
+
}
|
17
|
+
static withParameters(parameters) {
|
18
|
+
this.parameters = parameters;
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Make the value for the attribute.
|
23
|
+
*/
|
24
|
+
set(value) {
|
25
|
+
const nanoid$1 = this.$parameters?.alphabet ? customAlphabet(this.$parameters.alphabet) : nanoid;
|
26
|
+
return value ?? nanoid$1(this.$parameters?.size);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
__publicField(UidCast, "parameters");
|
30
|
+
|
31
|
+
function Uid(options) {
|
32
|
+
return (target, propertyKey) => {
|
33
|
+
const self = target.$self();
|
34
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
35
|
+
self.setRegistry(propertyKey, () => self.uid());
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,42 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const nonSecure = require('nanoid/non-secure');
|
4
|
+
const CastAttribute = require('../shared/pinia-orm.a7e3e0f3.cjs');
|
5
|
+
|
6
|
+
var __defProp = Object.defineProperty;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __publicField = (obj, key, value) => {
|
9
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
10
|
+
return value;
|
11
|
+
};
|
12
|
+
class UidCast extends CastAttribute.CastAttribute {
|
13
|
+
/**
|
14
|
+
* Create a new String attribute instance.
|
15
|
+
*/
|
16
|
+
constructor(attributes) {
|
17
|
+
super(attributes);
|
18
|
+
}
|
19
|
+
static withParameters(parameters) {
|
20
|
+
this.parameters = parameters;
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Make the value for the attribute.
|
25
|
+
*/
|
26
|
+
set(value) {
|
27
|
+
const nanoid = this.$parameters?.alphabet ? nonSecure.customAlphabet(this.$parameters.alphabet) : nonSecure.nanoid;
|
28
|
+
return value ?? nanoid(this.$parameters?.size);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
__publicField(UidCast, "parameters");
|
32
|
+
|
33
|
+
function Uid(options) {
|
34
|
+
return (target, propertyKey) => {
|
35
|
+
const self = target.$self();
|
36
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
37
|
+
self.setRegistry(propertyKey, () => self.uid());
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.Uid = Uid;
|
42
|
+
exports.UidCast = UidCast;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.cjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.mjs';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { $ as CastAttribute, aj as NanoidOptions, m as ModelFields, af as PropertyDecorator } from '../shared/pinia-orm.876a7cdc.js';
|
2
|
+
import 'pinia';
|
3
|
+
import '@pinia-orm/normalizr';
|
4
|
+
import '@/composables';
|
5
|
+
|
6
|
+
declare class UidCast extends CastAttribute {
|
7
|
+
static parameters?: NanoidOptions;
|
8
|
+
/**
|
9
|
+
* Create a new String attribute instance.
|
10
|
+
*/
|
11
|
+
constructor(attributes: ModelFields);
|
12
|
+
static withParameters(parameters?: NanoidOptions): typeof CastAttribute;
|
13
|
+
/**
|
14
|
+
* Make the value for the attribute.
|
15
|
+
*/
|
16
|
+
set(value: any): string | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a cast for an attribute property decorator.
|
21
|
+
*/
|
22
|
+
declare function Uid(options?: NanoidOptions): PropertyDecorator;
|
23
|
+
|
24
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { customAlphabet, nanoid } from 'nanoid/non-secure';
|
2
|
+
import { C as CastAttribute } from '../shared/pinia-orm.4ff2e12f.mjs';
|
3
|
+
|
4
|
+
var __defProp = Object.defineProperty;
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6
|
+
var __publicField = (obj, key, value) => {
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
8
|
+
return value;
|
9
|
+
};
|
10
|
+
class UidCast extends CastAttribute {
|
11
|
+
/**
|
12
|
+
* Create a new String attribute instance.
|
13
|
+
*/
|
14
|
+
constructor(attributes) {
|
15
|
+
super(attributes);
|
16
|
+
}
|
17
|
+
static withParameters(parameters) {
|
18
|
+
this.parameters = parameters;
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Make the value for the attribute.
|
23
|
+
*/
|
24
|
+
set(value) {
|
25
|
+
const nanoid$1 = this.$parameters?.alphabet ? customAlphabet(this.$parameters.alphabet) : nanoid;
|
26
|
+
return value ?? nanoid$1(this.$parameters?.size);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
__publicField(UidCast, "parameters");
|
30
|
+
|
31
|
+
function Uid(options) {
|
32
|
+
return (target, propertyKey) => {
|
33
|
+
const self = target.$self();
|
34
|
+
self.setCast(propertyKey, UidCast.withParameters(options));
|
35
|
+
self.setRegistry(propertyKey, () => self.uid());
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
export { Uid, UidCast };
|
@@ -0,0 +1,153 @@
|
|
1
|
+
function compareWithOperator(leftValue, rightValue, operator) {
|
2
|
+
switch (operator) {
|
3
|
+
case ">":
|
4
|
+
return leftValue > rightValue;
|
5
|
+
case ">=":
|
6
|
+
return leftValue >= rightValue;
|
7
|
+
case "<":
|
8
|
+
return leftValue < rightValue;
|
9
|
+
case "<=":
|
10
|
+
return leftValue <= rightValue;
|
11
|
+
case "=":
|
12
|
+
return leftValue === rightValue;
|
13
|
+
case "!=":
|
14
|
+
return leftValue !== rightValue;
|
15
|
+
default:
|
16
|
+
return leftValue === rightValue;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
function isNullish(value) {
|
20
|
+
return value === void 0 || value === null;
|
21
|
+
}
|
22
|
+
function isArray(value) {
|
23
|
+
return Array.isArray(value);
|
24
|
+
}
|
25
|
+
function isFunction(value) {
|
26
|
+
return typeof value === "function";
|
27
|
+
}
|
28
|
+
function isEmpty(collection) {
|
29
|
+
return size(collection) === 0;
|
30
|
+
}
|
31
|
+
function size(collection) {
|
32
|
+
return isArray(collection) ? collection.length : Object.keys(collection).length;
|
33
|
+
}
|
34
|
+
function orderBy(collection, iteratees, directions, flags = "SORT_REGULAR") {
|
35
|
+
let index = -1;
|
36
|
+
const result = collection.map((value) => {
|
37
|
+
const criteria = iteratees.map((iteratee) => {
|
38
|
+
return typeof iteratee === "function" ? iteratee(value) : value[iteratee];
|
39
|
+
});
|
40
|
+
return { criteria, index: ++index, value };
|
41
|
+
});
|
42
|
+
return baseSortBy(result, (object, other) => {
|
43
|
+
return compareMultiple(object, other, directions, flags);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
function baseSortBy(array, comparer) {
|
47
|
+
let length = array.length;
|
48
|
+
array.sort(comparer);
|
49
|
+
const newArray = [];
|
50
|
+
while (length--) {
|
51
|
+
newArray[length] = array[length].value;
|
52
|
+
}
|
53
|
+
return newArray;
|
54
|
+
}
|
55
|
+
function compareMultiple(object, other, directions, flags) {
|
56
|
+
let index = -1;
|
57
|
+
const objCriteria = object.criteria;
|
58
|
+
const othCriteria = other.criteria;
|
59
|
+
const length = objCriteria.length;
|
60
|
+
while (++index < length) {
|
61
|
+
const result = compareAscending(objCriteria[index], othCriteria[index], flags);
|
62
|
+
if (result) {
|
63
|
+
const direction = directions[index];
|
64
|
+
return result * (direction === "desc" ? -1 : 1);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return object.index - other.index;
|
68
|
+
}
|
69
|
+
function compareAscending(value, other, flags) {
|
70
|
+
if (value !== other) {
|
71
|
+
const valIsDefined = value !== void 0;
|
72
|
+
const valIsNull = value === null;
|
73
|
+
const valIsReflexive = value === value;
|
74
|
+
const othIsDefined = other !== void 0;
|
75
|
+
const othIsNull = other === null;
|
76
|
+
if (typeof value !== "number" || typeof other !== "number") {
|
77
|
+
value = String(value);
|
78
|
+
other = String(other);
|
79
|
+
if (flags === "SORT_FLAG_CASE") {
|
80
|
+
value = value.toUpperCase();
|
81
|
+
other = other.toUpperCase();
|
82
|
+
}
|
83
|
+
}
|
84
|
+
if (!othIsNull && value > other || valIsNull && othIsDefined || !valIsDefined || !valIsReflexive) {
|
85
|
+
return 1;
|
86
|
+
}
|
87
|
+
return -1;
|
88
|
+
}
|
89
|
+
return 0;
|
90
|
+
}
|
91
|
+
function groupBy(collection, iteratee) {
|
92
|
+
return collection.reduce((records, record) => {
|
93
|
+
const key = iteratee(record);
|
94
|
+
if (records[key] === void 0) {
|
95
|
+
records[key] = [];
|
96
|
+
}
|
97
|
+
records[key].push(record);
|
98
|
+
return records;
|
99
|
+
}, {});
|
100
|
+
}
|
101
|
+
function throwError(message) {
|
102
|
+
throw new Error(["[Pinia ORM]"].concat(message).join(" "));
|
103
|
+
}
|
104
|
+
function assert(condition, message) {
|
105
|
+
if (!condition) {
|
106
|
+
throwError(message);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
function generateId(size2, alphabet) {
|
110
|
+
let id = "";
|
111
|
+
let i = size2;
|
112
|
+
while (i--) {
|
113
|
+
id += alphabet[Math.random() * 64 | 0];
|
114
|
+
}
|
115
|
+
return id;
|
116
|
+
}
|
117
|
+
function generateKey(key, params) {
|
118
|
+
const keyValues = params ? { key, params } : { key };
|
119
|
+
const stringifiedKey = JSON.stringify(keyValues);
|
120
|
+
return typeof process === "undefined" ? btoa(stringifiedKey) : stringifiedKey;
|
121
|
+
}
|
122
|
+
function getValue(obj, keys) {
|
123
|
+
keys = typeof keys === "string" ? keys.split(".") : keys;
|
124
|
+
const key = keys.shift();
|
125
|
+
if (obj && obj.hasOwnProperty(key) && keys.length === 0) {
|
126
|
+
return obj[key];
|
127
|
+
} else if (!obj || !obj.hasOwnProperty(key)) {
|
128
|
+
return obj;
|
129
|
+
} else {
|
130
|
+
return getValue(obj[key], keys);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
function equals(a, b) {
|
134
|
+
if (a === b) {
|
135
|
+
return true;
|
136
|
+
}
|
137
|
+
if (a instanceof Date && b instanceof Date) {
|
138
|
+
return a.getTime() === b.getTime();
|
139
|
+
}
|
140
|
+
if (!a || !b || typeof a !== "object" && typeof b !== "object") {
|
141
|
+
return a === b;
|
142
|
+
}
|
143
|
+
if (a.prototype !== b.prototype) {
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
const keys = Object.keys(a);
|
147
|
+
if (keys.length !== Object.keys(b).length) {
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
return keys.every((k) => equals(a[k], b[k]));
|
151
|
+
}
|
152
|
+
|
153
|
+
export { assert as a, isNullish as b, compareWithOperator as c, generateKey as d, isEmpty as e, isFunction as f, generateId as g, groupBy as h, isArray as i, equals as j, getValue as k, orderBy as o, throwError as t };
|