repository-provider 35.5.16 → 35.6.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 +112 -259
- package/package.json +8 -7
- package/src/base-object.mjs +8 -20
- package/src/base-provider.mjs +12 -66
- package/src/hook.mjs +17 -5
- package/src/index.mjs +0 -1
- package/src/milestone.mjs +2 -2
- package/src/named-object.mjs +9 -21
- package/src/owned-object.mjs +2 -2
- package/src/pull-request.mjs +56 -53
- package/src/ref.mjs +3 -7
- package/src/repository-group.mjs +2 -7
- package/src/repository.mjs +15 -15
- package/types/base-object.d.mts +2 -8
- package/types/base-provider.d.mts +10 -17
- package/types/branch.d.mts +0 -1
- package/types/hook.d.mts +30 -5
- package/types/index.d.mts +0 -1
- package/types/named-object.d.mts +3 -5
- package/types/owned-object.d.mts +1 -1
- package/types/pull-request.d.mts +11 -3
- package/types/ref.d.mts +0 -3
- package/types/repository-group.d.mts +0 -4
- package/types/repository.d.mts +115 -9
- package/src/attribute-extras.mjs +0 -171
- package/types/attribute-extras.d.mts +0 -52
|
@@ -33,28 +33,13 @@ export class BaseProvider extends BaseObject {
|
|
|
33
33
|
* @return {string} identifier for environment options
|
|
34
34
|
*/
|
|
35
35
|
static get instanceIdentifier(): string;
|
|
36
|
-
/**
|
|
37
|
-
* Extract options suitable for the constructor.
|
|
38
|
-
* Form the given set of environment variables.
|
|
39
|
-
* Object with the detected key value pairs is delivered.
|
|
40
|
-
* @param {Object} [env] as from process.env
|
|
41
|
-
* @param {string} instanceIdentifier part of variable name.
|
|
42
|
-
* @return {Object|undefined} undefined if no suitable environment variables have been found
|
|
43
|
-
*/
|
|
44
|
-
static optionsFromEnvironment(env?: any, instanceIdentifier?: string): any | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Check if given options are sufficient to create a provider.
|
|
47
|
-
* @param {Object} options
|
|
48
|
-
* @return {boolean} true if options ar sufficient to construct a provider
|
|
49
|
-
*/
|
|
50
|
-
static areOptionsSufficcient(options: any): boolean;
|
|
51
36
|
static attributes: {
|
|
52
37
|
/**
|
|
53
38
|
* Name of the provider.
|
|
54
39
|
*/
|
|
55
40
|
name: {
|
|
56
41
|
env: string;
|
|
57
|
-
type:
|
|
42
|
+
type: object;
|
|
58
43
|
isKey: boolean;
|
|
59
44
|
writable: boolean;
|
|
60
45
|
mandatory: boolean;
|
|
@@ -65,6 +50,10 @@ export class BaseProvider extends BaseObject {
|
|
|
65
50
|
default?: any;
|
|
66
51
|
set?: Function;
|
|
67
52
|
get?: Function;
|
|
53
|
+
prepareValue?: Function;
|
|
54
|
+
values?: Set<any>;
|
|
55
|
+
externalName?: string;
|
|
56
|
+
additionalValues?: object;
|
|
68
57
|
};
|
|
69
58
|
url: import("pacc").AttributeDefinition;
|
|
70
59
|
priority: import("pacc").AttributeDefinition;
|
|
@@ -72,10 +61,10 @@ export class BaseProvider extends BaseObject {
|
|
|
72
61
|
* To forward info/warn and error messages to
|
|
73
62
|
*/
|
|
74
63
|
messageDestination: {
|
|
75
|
-
type: string;
|
|
76
64
|
default: Console;
|
|
77
65
|
writable: boolean;
|
|
78
66
|
private: boolean;
|
|
67
|
+
type: object;
|
|
79
68
|
isKey: boolean;
|
|
80
69
|
mandatory: boolean;
|
|
81
70
|
collection: boolean;
|
|
@@ -83,7 +72,11 @@ export class BaseProvider extends BaseObject {
|
|
|
83
72
|
description?: string;
|
|
84
73
|
set?: Function;
|
|
85
74
|
get?: Function;
|
|
75
|
+
prepareValue?: Function;
|
|
76
|
+
values?: Set<any>;
|
|
77
|
+
externalName?: string;
|
|
86
78
|
env?: string[] | string;
|
|
79
|
+
additionalValues?: object;
|
|
87
80
|
};
|
|
88
81
|
id: import("pacc").AttributeDefinition;
|
|
89
82
|
description: import("pacc").AttributeDefinition;
|
package/types/branch.d.mts
CHANGED
package/types/hook.d.mts
CHANGED
|
@@ -8,9 +8,9 @@ export class Hook extends OwnedObject {
|
|
|
8
8
|
secret: import("pacc").AttributeDefinition;
|
|
9
9
|
url: {
|
|
10
10
|
description: string;
|
|
11
|
-
|
|
12
|
-
type: string;
|
|
11
|
+
type: object;
|
|
13
12
|
isKey: boolean;
|
|
13
|
+
writable: boolean;
|
|
14
14
|
mandatory: boolean;
|
|
15
15
|
collection: boolean;
|
|
16
16
|
private?: boolean;
|
|
@@ -18,13 +18,17 @@ export class Hook extends OwnedObject {
|
|
|
18
18
|
default?: any;
|
|
19
19
|
set?: Function;
|
|
20
20
|
get?: Function;
|
|
21
|
+
prepareValue?: Function;
|
|
22
|
+
values?: Set<any>;
|
|
23
|
+
externalName?: string;
|
|
21
24
|
env?: string[] | string;
|
|
25
|
+
additionalValues?: object;
|
|
22
26
|
};
|
|
23
27
|
content_type: {
|
|
24
28
|
default: string;
|
|
25
|
-
|
|
26
|
-
type: string;
|
|
29
|
+
type: object;
|
|
27
30
|
isKey: boolean;
|
|
31
|
+
writable: boolean;
|
|
28
32
|
mandatory: boolean;
|
|
29
33
|
collection: boolean;
|
|
30
34
|
private?: boolean;
|
|
@@ -32,17 +36,38 @@ export class Hook extends OwnedObject {
|
|
|
32
36
|
description?: string;
|
|
33
37
|
set?: Function;
|
|
34
38
|
get?: Function;
|
|
39
|
+
prepareValue?: Function;
|
|
40
|
+
values?: Set<any>;
|
|
41
|
+
externalName?: string;
|
|
35
42
|
env?: string[] | string;
|
|
43
|
+
additionalValues?: object;
|
|
36
44
|
};
|
|
37
45
|
insecure_ssl: import("pacc").AttributeDefinition;
|
|
38
46
|
events: {
|
|
39
|
-
type: string;
|
|
40
47
|
default: Set<string>;
|
|
48
|
+
type: object;
|
|
49
|
+
isKey: boolean;
|
|
50
|
+
writable: boolean;
|
|
51
|
+
mandatory: boolean;
|
|
52
|
+
collection: boolean;
|
|
53
|
+
private?: boolean;
|
|
54
|
+
depends?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
set?: Function;
|
|
57
|
+
get?: Function;
|
|
58
|
+
prepareValue?: Function;
|
|
59
|
+
values?: Set<any>;
|
|
60
|
+
externalName?: string;
|
|
61
|
+
env?: string[] | string;
|
|
62
|
+
additionalValues?: object;
|
|
41
63
|
};
|
|
42
64
|
name: import("pacc").AttributeDefinition;
|
|
43
65
|
id: import("pacc").AttributeDefinition;
|
|
44
66
|
description: import("pacc").AttributeDefinition;
|
|
45
67
|
};
|
|
46
68
|
static get delteteMethodName(): string;
|
|
69
|
+
set events(value: Set<any>);
|
|
70
|
+
get events(): Set<any>;
|
|
71
|
+
_events: any;
|
|
47
72
|
}
|
|
48
73
|
import { OwnedObject } from "./owned-object.mjs";
|
package/types/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@ export * from "./hook.mjs";
|
|
|
15
15
|
export * from "./milestone.mjs";
|
|
16
16
|
export * from "./review.mjs";
|
|
17
17
|
export * from "./application.mjs";
|
|
18
|
-
export * from "./attribute-extras.mjs";
|
|
19
18
|
export * from "./util.mjs";
|
|
20
19
|
export { OwnedObject } from "./owned-object.mjs";
|
|
21
20
|
export { BaseProvider } from "./base-provider.mjs";
|
package/types/named-object.d.mts
CHANGED
|
@@ -15,9 +15,8 @@ export class NamedObject extends BaseObject {
|
|
|
15
15
|
id: import("pacc").AttributeDefinition;
|
|
16
16
|
description: import("pacc").AttributeDefinition;
|
|
17
17
|
};
|
|
18
|
-
constructor(name: any, options: any
|
|
19
|
-
|
|
20
|
-
get name(): string;
|
|
18
|
+
constructor(name: any, options: any);
|
|
19
|
+
name: any;
|
|
21
20
|
/**
|
|
22
21
|
* Beautified name use for human displaying only.
|
|
23
22
|
* @return {string} human readable name
|
|
@@ -42,7 +41,6 @@ export class NamedObject extends BaseObject {
|
|
|
42
41
|
/**
|
|
43
42
|
* Provided name and all defined attributes.
|
|
44
43
|
*/
|
|
45
|
-
toJSON(): any;
|
|
46
|
-
#private;
|
|
44
|
+
toJSON(filter: any): any;
|
|
47
45
|
}
|
|
48
46
|
import { BaseObject } from "./base-object.mjs";
|
package/types/owned-object.d.mts
CHANGED
|
@@ -18,7 +18,7 @@ export class OwnedObject extends NamedObject {
|
|
|
18
18
|
* @return {string}
|
|
19
19
|
*/
|
|
20
20
|
static get deleteMethodName(): string;
|
|
21
|
-
constructor(owner: any, name: any, options: any
|
|
21
|
+
constructor(owner: any, name: any, options: any);
|
|
22
22
|
owner: any;
|
|
23
23
|
/**
|
|
24
24
|
* Removes the receiver from the owner.
|
package/types/pull-request.d.mts
CHANGED
|
@@ -73,7 +73,7 @@ export class PullRequest extends OwnedObject {
|
|
|
73
73
|
state: {
|
|
74
74
|
default: string;
|
|
75
75
|
values: Set<string>;
|
|
76
|
-
type:
|
|
76
|
+
type: object;
|
|
77
77
|
isKey: boolean;
|
|
78
78
|
writable: boolean;
|
|
79
79
|
mandatory: boolean;
|
|
@@ -83,7 +83,10 @@ export class PullRequest extends OwnedObject {
|
|
|
83
83
|
description?: string;
|
|
84
84
|
set?: Function;
|
|
85
85
|
get?: Function;
|
|
86
|
+
prepareValue?: Function;
|
|
87
|
+
externalName?: string;
|
|
86
88
|
env?: string[] | string;
|
|
89
|
+
additionalValues?: object;
|
|
87
90
|
};
|
|
88
91
|
/**
|
|
89
92
|
* Locked state of the pull request.
|
|
@@ -106,9 +109,15 @@ export class PullRequest extends OwnedObject {
|
|
|
106
109
|
id: import("pacc").AttributeDefinition;
|
|
107
110
|
description: import("pacc").AttributeDefinition;
|
|
108
111
|
};
|
|
112
|
+
constructor(source: any, owner: any, name: any, options: any);
|
|
109
113
|
/** @type {Branch} */ source: Branch;
|
|
114
|
+
_state: string;
|
|
115
|
+
set state(value: string);
|
|
116
|
+
get state(): string;
|
|
117
|
+
set merged(value: boolean);
|
|
118
|
+
get merged(): boolean;
|
|
110
119
|
get destination(): any;
|
|
111
|
-
get number():
|
|
120
|
+
get number(): any;
|
|
112
121
|
get dry(): boolean;
|
|
113
122
|
/**
|
|
114
123
|
* @return {Repository} destination repository
|
|
@@ -125,7 +134,6 @@ export class PullRequest extends OwnedObject {
|
|
|
125
134
|
* @param {string} method
|
|
126
135
|
*/
|
|
127
136
|
merge(method?: string): Promise<void>;
|
|
128
|
-
merged: boolean;
|
|
129
137
|
/**
|
|
130
138
|
* Decline the pull request.
|
|
131
139
|
*/
|
package/types/ref.d.mts
CHANGED
|
@@ -47,10 +47,6 @@ export class RepositoryGroup extends RepositoryGroup_base {
|
|
|
47
47
|
static get type(): string;
|
|
48
48
|
static get collectionName(): string;
|
|
49
49
|
static attributes: any;
|
|
50
|
-
/**
|
|
51
|
-
* Map attributes between external and internal representation.
|
|
52
|
-
*/
|
|
53
|
-
static attributeMapping(): void;
|
|
54
50
|
get isAdmin(): boolean;
|
|
55
51
|
get areRepositoryNamesCaseSensitive(): any;
|
|
56
52
|
get areRepositoryGroupNamesCaseSensitive(): any;
|
package/types/repository.d.mts
CHANGED
|
@@ -23,7 +23,8 @@ export class Repository extends OwnedObject {
|
|
|
23
23
|
*/
|
|
24
24
|
defaultBranchName: {
|
|
25
25
|
default: string;
|
|
26
|
-
|
|
26
|
+
externalName: string;
|
|
27
|
+
type: object;
|
|
27
28
|
isKey: boolean;
|
|
28
29
|
writable: boolean;
|
|
29
30
|
mandatory: boolean;
|
|
@@ -33,14 +34,120 @@ export class Repository extends OwnedObject {
|
|
|
33
34
|
description?: string;
|
|
34
35
|
set?: Function;
|
|
35
36
|
get?: Function;
|
|
37
|
+
prepareValue?: Function;
|
|
38
|
+
values?: Set<any>;
|
|
36
39
|
env?: string[] | string;
|
|
40
|
+
additionalValues?: object;
|
|
37
41
|
};
|
|
38
42
|
cloneURL: import("pacc").AttributeDefinition;
|
|
39
|
-
isArchived:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
isArchived: {
|
|
44
|
+
externalName: string;
|
|
45
|
+
type: object;
|
|
46
|
+
isKey: boolean;
|
|
47
|
+
writable: boolean;
|
|
48
|
+
mandatory: boolean;
|
|
49
|
+
collection: boolean;
|
|
50
|
+
private?: boolean;
|
|
51
|
+
depends?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
default?: any;
|
|
54
|
+
set?: Function;
|
|
55
|
+
get?: Function;
|
|
56
|
+
prepareValue?: Function;
|
|
57
|
+
values?: Set<any>;
|
|
58
|
+
env?: string[] | string;
|
|
59
|
+
additionalValues?: object;
|
|
60
|
+
};
|
|
61
|
+
isLocked: {
|
|
62
|
+
externalName: string;
|
|
63
|
+
type: object;
|
|
64
|
+
isKey: boolean;
|
|
65
|
+
writable: boolean;
|
|
66
|
+
mandatory: boolean;
|
|
67
|
+
collection: boolean;
|
|
68
|
+
private?: boolean;
|
|
69
|
+
depends?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
default?: any;
|
|
72
|
+
set?: Function;
|
|
73
|
+
get?: Function;
|
|
74
|
+
prepareValue?: Function;
|
|
75
|
+
values?: Set<any>;
|
|
76
|
+
env?: string[] | string;
|
|
77
|
+
additionalValues?: object;
|
|
78
|
+
};
|
|
79
|
+
isDisabled: {
|
|
80
|
+
externalName: string;
|
|
81
|
+
type: object;
|
|
82
|
+
isKey: boolean;
|
|
83
|
+
writable: boolean;
|
|
84
|
+
mandatory: boolean;
|
|
85
|
+
collection: boolean;
|
|
86
|
+
private?: boolean;
|
|
87
|
+
depends?: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
default?: any;
|
|
90
|
+
set?: Function;
|
|
91
|
+
get?: Function;
|
|
92
|
+
prepareValue?: Function;
|
|
93
|
+
values?: Set<any>;
|
|
94
|
+
env?: string[] | string;
|
|
95
|
+
additionalValues?: object;
|
|
96
|
+
};
|
|
97
|
+
isTemplate: {
|
|
98
|
+
externalName: string;
|
|
99
|
+
type: object;
|
|
100
|
+
isKey: boolean;
|
|
101
|
+
writable: boolean;
|
|
102
|
+
mandatory: boolean;
|
|
103
|
+
collection: boolean;
|
|
104
|
+
private?: boolean;
|
|
105
|
+
depends?: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
default?: any;
|
|
108
|
+
set?: Function;
|
|
109
|
+
get?: Function;
|
|
110
|
+
prepareValue?: Function;
|
|
111
|
+
values?: Set<any>;
|
|
112
|
+
env?: string[] | string;
|
|
113
|
+
additionalValues?: object;
|
|
114
|
+
};
|
|
115
|
+
isFork: {
|
|
116
|
+
externalName: string;
|
|
117
|
+
type: object;
|
|
118
|
+
isKey: boolean;
|
|
119
|
+
writable: boolean;
|
|
120
|
+
mandatory: boolean;
|
|
121
|
+
collection: boolean;
|
|
122
|
+
private?: boolean;
|
|
123
|
+
depends?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
default?: any;
|
|
126
|
+
set?: Function;
|
|
127
|
+
get?: Function;
|
|
128
|
+
prepareValue?: Function;
|
|
129
|
+
values?: Set<any>;
|
|
130
|
+
env?: string[] | string;
|
|
131
|
+
additionalValues?: object;
|
|
132
|
+
};
|
|
133
|
+
isPrivate: {
|
|
134
|
+
externalName: string;
|
|
135
|
+
type: object;
|
|
136
|
+
isKey: boolean;
|
|
137
|
+
writable: boolean;
|
|
138
|
+
mandatory: boolean;
|
|
139
|
+
collection: boolean;
|
|
140
|
+
private?: boolean;
|
|
141
|
+
depends?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
default?: any;
|
|
144
|
+
set?: Function;
|
|
145
|
+
get?: Function;
|
|
146
|
+
prepareValue?: Function;
|
|
147
|
+
values?: Set<any>;
|
|
148
|
+
env?: string[] | string;
|
|
149
|
+
additionalValues?: object;
|
|
150
|
+
};
|
|
44
151
|
name: import("pacc").AttributeDefinition;
|
|
45
152
|
id: import("pacc").AttributeDefinition;
|
|
46
153
|
description: import("pacc").AttributeDefinition;
|
|
@@ -54,13 +161,12 @@ export class Repository extends OwnedObject {
|
|
|
54
161
|
* @param {Object} [options]
|
|
55
162
|
* @param {string} [options.id]
|
|
56
163
|
* @param {string} [options.description]
|
|
57
|
-
* @param {Object} [additionalProperties]
|
|
58
164
|
*/
|
|
59
165
|
constructor(owner: typeof RepositoryOwner, name: string, options?: {
|
|
60
166
|
description?: string;
|
|
61
167
|
id?: string;
|
|
62
|
-
}
|
|
63
|
-
get defaultBranchName():
|
|
168
|
+
});
|
|
169
|
+
get defaultBranchName(): any;
|
|
64
170
|
/**
|
|
65
171
|
* Lookup entries form the head of the default branch.
|
|
66
172
|
* {@link Branch#entry}
|
package/src/attribute-extras.mjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { setAttribute, getAttribute } from "pacc";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create properties from options and default options.
|
|
5
|
-
* Already present properties (direct) are skipped.
|
|
6
|
-
* The attribute list from the class will be applied to the
|
|
7
|
-
* options and merged with the given set of properties.
|
|
8
|
-
* ```js
|
|
9
|
-
* class aClass {
|
|
10
|
-
* static attributes = {
|
|
11
|
-
* with_default: { default: 77 }
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* definePropertiesFromOptions(new aClass());
|
|
16
|
-
* // equivalent to
|
|
17
|
-
* Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
|
|
18
|
-
* ```
|
|
19
|
-
* @see Object.definedProperties()
|
|
20
|
-
* @see Object.getOwnPropertyDescriptor()
|
|
21
|
-
* @param {Object} object target object
|
|
22
|
-
* @param {Object} options as passed to object constructor. Used as values for the attributes.
|
|
23
|
-
* @param {Object} properties object properties
|
|
24
|
-
* @param {Object} [attributes] attribute meta info
|
|
25
|
-
*/
|
|
26
|
-
export function definePropertiesFromOptions(
|
|
27
|
-
object,
|
|
28
|
-
options = {},
|
|
29
|
-
properties = {},
|
|
30
|
-
attributes = object.constructor.attributes
|
|
31
|
-
) {
|
|
32
|
-
const applyLater = {};
|
|
33
|
-
|
|
34
|
-
if (attributes !== undefined) {
|
|
35
|
-
Object.entries(attributes).forEach(([name, attribute]) => {
|
|
36
|
-
let value = getAttribute(options, name);
|
|
37
|
-
|
|
38
|
-
if (value === undefined) {
|
|
39
|
-
if (attribute.get) {
|
|
40
|
-
value = attribute.get(attribute, object, properties);
|
|
41
|
-
} else if (
|
|
42
|
-
attribute.default !== undefined &&
|
|
43
|
-
attribute.default !== getAttribute(object, name)
|
|
44
|
-
) {
|
|
45
|
-
value = attribute.default;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (attribute.set) {
|
|
50
|
-
value = attribute.set(value);
|
|
51
|
-
} else {
|
|
52
|
-
switch (attribute.type) {
|
|
53
|
-
case "set":
|
|
54
|
-
if (Array.isArray(value)) {
|
|
55
|
-
value = new Set(value);
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
case "boolean":
|
|
59
|
-
if (value !== undefined) {
|
|
60
|
-
value =
|
|
61
|
-
value === 0 || value === "0" || value === false ? false : true;
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const path = name.split(/\./);
|
|
68
|
-
const first = path.shift();
|
|
69
|
-
|
|
70
|
-
if (first !== undefined) {
|
|
71
|
-
const property = properties[first];
|
|
72
|
-
|
|
73
|
-
if (path.length) {
|
|
74
|
-
const remaining = path.join(".");
|
|
75
|
-
|
|
76
|
-
if (property) {
|
|
77
|
-
setAttribute(property.value, remaining, value);
|
|
78
|
-
} else {
|
|
79
|
-
const slice = {};
|
|
80
|
-
setAttribute(slice, remaining, value);
|
|
81
|
-
properties[first] = { configurable: true, value: slice };
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
if (value !== undefined) {
|
|
85
|
-
const op = Object.getOwnPropertyDescriptor(
|
|
86
|
-
object.constructor.prototype,
|
|
87
|
-
first
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
if (op?.set || property?.set) {
|
|
91
|
-
applyLater[first] = value;
|
|
92
|
-
} else {
|
|
93
|
-
properties[first] = Object.assign(
|
|
94
|
-
{ value, writable: attribute.writable },
|
|
95
|
-
property
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Object.defineProperties(object, properties);
|
|
105
|
-
Object.assign(object, applyLater);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Create json based on present options.
|
|
110
|
-
* In other words only produce key value pairs if value is defined.
|
|
111
|
-
* @param {Object} object
|
|
112
|
-
* @param {Object} initial
|
|
113
|
-
* @param {Object} attributes to operator on
|
|
114
|
-
* @return {Object} initial + defined values
|
|
115
|
-
*/
|
|
116
|
-
export function optionJSON(
|
|
117
|
-
object,
|
|
118
|
-
initial = {},
|
|
119
|
-
attributes = object.constructor.attributes
|
|
120
|
-
) {
|
|
121
|
-
return attributes
|
|
122
|
-
? Object.keys(attributes).reduce((a, c) => {
|
|
123
|
-
const value = object[c];
|
|
124
|
-
if (value !== undefined && !(value instanceof Function)) {
|
|
125
|
-
a[c] = value instanceof Set ? [...value] : value;
|
|
126
|
-
}
|
|
127
|
-
return a;
|
|
128
|
-
}, initial)
|
|
129
|
-
: initial;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Rename attributes.
|
|
134
|
-
* Filters out null, undefined and empty strings.
|
|
135
|
-
* ```js
|
|
136
|
-
* mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
|
|
137
|
-
* ```
|
|
138
|
-
* @param {Object} object
|
|
139
|
-
* @param {Object} mapping
|
|
140
|
-
* @return {Object} keys renamed after mapping
|
|
141
|
-
*/
|
|
142
|
-
export function mapAttributes(object, mapping) {
|
|
143
|
-
if (object !== undefined) {
|
|
144
|
-
const o = {};
|
|
145
|
-
|
|
146
|
-
for (const k of Object.keys(object)) {
|
|
147
|
-
const v = getAttribute(object, k);
|
|
148
|
-
if (v !== undefined && v !== null && v !== "") {
|
|
149
|
-
setAttribute(o, mapping[k] || k, v);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return o;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Same as mapAttributes but with the inverse mapping.
|
|
159
|
-
* Filters out null, undefined and empty strings
|
|
160
|
-
* @param {Object} object
|
|
161
|
-
* @param {Object} [mapping]
|
|
162
|
-
* @return {Object} keys renamed after mapping
|
|
163
|
-
*/
|
|
164
|
-
export function mapAttributesInverse(object, mapping) {
|
|
165
|
-
return mapping === undefined
|
|
166
|
-
? object
|
|
167
|
-
: mapAttributes(
|
|
168
|
-
object,
|
|
169
|
-
Object.fromEntries(Object.entries(mapping).map(([k, v]) => [v, k]))
|
|
170
|
-
);
|
|
171
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create properties from options and default options.
|
|
3
|
-
* Already present properties (direct) are skipped.
|
|
4
|
-
* The attribute list from the class will be applied to the
|
|
5
|
-
* options and merged with the given set of properties.
|
|
6
|
-
* ```js
|
|
7
|
-
* class aClass {
|
|
8
|
-
* static attributes = {
|
|
9
|
-
* with_default: { default: 77 }
|
|
10
|
-
* }
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* definePropertiesFromOptions(new aClass());
|
|
14
|
-
* // equivalent to
|
|
15
|
-
* Object.definedProperties(new aClass(),{ with_default: { value: 77 }})
|
|
16
|
-
* ```
|
|
17
|
-
* @see Object.definedProperties()
|
|
18
|
-
* @see Object.getOwnPropertyDescriptor()
|
|
19
|
-
* @param {Object} object target object
|
|
20
|
-
* @param {Object} options as passed to object constructor. Used as values for the attributes.
|
|
21
|
-
* @param {Object} properties object properties
|
|
22
|
-
* @param {Object} [attributes] attribute meta info
|
|
23
|
-
*/
|
|
24
|
-
export function definePropertiesFromOptions(object: any, options?: any, properties?: any, attributes?: any): void;
|
|
25
|
-
/**
|
|
26
|
-
* Create json based on present options.
|
|
27
|
-
* In other words only produce key value pairs if value is defined.
|
|
28
|
-
* @param {Object} object
|
|
29
|
-
* @param {Object} initial
|
|
30
|
-
* @param {Object} attributes to operator on
|
|
31
|
-
* @return {Object} initial + defined values
|
|
32
|
-
*/
|
|
33
|
-
export function optionJSON(object: any, initial?: any, attributes?: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Rename attributes.
|
|
36
|
-
* Filters out null, undefined and empty strings.
|
|
37
|
-
* ```js
|
|
38
|
-
* mapAttributes({a:1},{a:"a'"}) // {"a'": 1}
|
|
39
|
-
* ```
|
|
40
|
-
* @param {Object} object
|
|
41
|
-
* @param {Object} mapping
|
|
42
|
-
* @return {Object} keys renamed after mapping
|
|
43
|
-
*/
|
|
44
|
-
export function mapAttributes(object: any, mapping: any): any;
|
|
45
|
-
/**
|
|
46
|
-
* Same as mapAttributes but with the inverse mapping.
|
|
47
|
-
* Filters out null, undefined and empty strings
|
|
48
|
-
* @param {Object} object
|
|
49
|
-
* @param {Object} [mapping]
|
|
50
|
-
* @return {Object} keys renamed after mapping
|
|
51
|
-
*/
|
|
52
|
-
export function mapAttributesInverse(object: any, mapping?: any): any;
|