@zucker-framework/relation 1.0.0
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 +201 -0
- package/NOTICE +22 -0
- package/THIRD_PARTY_NOTICES +4 -0
- package/dist/index.d.mts +194 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.js +325 -0
- package/dist/index.mjs +293 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Zucker Framework
|
|
2
|
+
Copyright 2026 Lind and Zucker Framework contributors
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0. See LICENSE.
|
|
5
|
+
|
|
6
|
+
The framework includes TypeScript adaptations and enhancements of concepts and
|
|
7
|
+
implementations from hsweb-framework and jetlinks-community, both distributed
|
|
8
|
+
under the Apache License, Version 2.0. Individual packages use different subsets
|
|
9
|
+
of the framework. The TypeScript adaptations and Node.js integrations were
|
|
10
|
+
modified for Zucker Framework; they are not the original upstream distribution.
|
|
11
|
+
|
|
12
|
+
hsweb-framework
|
|
13
|
+
https://github.com/hs-web/hsweb-framework
|
|
14
|
+
Copyright 2020 http://hsweb.me
|
|
15
|
+
|
|
16
|
+
jetlinks-community
|
|
17
|
+
https://github.com/jetlinks/jetlinks-community
|
|
18
|
+
|
|
19
|
+
See THIRD_PARTY_NOTICES for license texts and attribution for bundled dependencies
|
|
20
|
+
and reference implementations relevant to this package. External dependencies
|
|
21
|
+
remain subject to their own licenses. This NOTICE is informational and does not
|
|
22
|
+
modify any license or grant rights to upstream trademarks.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
interface PropertyDefinition {
|
|
4
|
+
key: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
}
|
|
9
|
+
type RelationType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
10
|
+
type RelationDirection = 'forward' | 'reverse' | 'bidirectional';
|
|
11
|
+
interface RelationDefinition {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
targetType: string;
|
|
15
|
+
relationType: RelationType;
|
|
16
|
+
direction: RelationDirection;
|
|
17
|
+
/** Extra metadata. Mirrors Java Relation.expands. */
|
|
18
|
+
expands?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Object type definition.
|
|
22
|
+
* Mirrors Java ObjectType with description, expands, and relatedTypes.
|
|
23
|
+
*/
|
|
24
|
+
interface ObjectType {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
/** Description of the object type. Mirrors Java ObjectType.getDescription(). */
|
|
28
|
+
description?: string;
|
|
29
|
+
properties: PropertyDefinition[];
|
|
30
|
+
relations: RelationDefinition[];
|
|
31
|
+
/** Related object types. Mirrors Java ObjectType.getRelatedTypes(). */
|
|
32
|
+
relatedTypes?: ObjectType[];
|
|
33
|
+
/** Extension metadata. Mirrors Java ObjectType.getExpands(). */
|
|
34
|
+
expands?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Composite object type — merges two ObjectTypes, with main taking precedence
|
|
38
|
+
* for scalar fields and both contributing to list fields.
|
|
39
|
+
* Mirrors Java CompositeObjectType.
|
|
40
|
+
*/
|
|
41
|
+
declare class CompositeObjectType implements ObjectType {
|
|
42
|
+
private readonly main;
|
|
43
|
+
private readonly second;
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly description?: string;
|
|
47
|
+
readonly expands?: Record<string, unknown>;
|
|
48
|
+
constructor(main: ObjectType, second: ObjectType);
|
|
49
|
+
get properties(): PropertyDefinition[];
|
|
50
|
+
get relations(): RelationDefinition[];
|
|
51
|
+
get relatedTypes(): ObjectType[];
|
|
52
|
+
}
|
|
53
|
+
/** Well-known object type ids. Mirrors Java RelationObjectProvider constants. */
|
|
54
|
+
declare const OBJECT_TYPE_IDS: {
|
|
55
|
+
readonly USER: "user";
|
|
56
|
+
readonly DEVICE: "device";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Relation object provider SPI.
|
|
60
|
+
* Mirrors Java RelationObjectProvider interface.
|
|
61
|
+
*/
|
|
62
|
+
interface RelationObjectProvider {
|
|
63
|
+
/** The object type id this provider handles. */
|
|
64
|
+
getTypeId(): string;
|
|
65
|
+
/** Get the full ObjectType definition. */
|
|
66
|
+
getType(): Promise<ObjectType>;
|
|
67
|
+
/** Get property values for a specific object instance. */
|
|
68
|
+
getProperties?(id: string): Promise<Record<string, unknown>>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 对象类型注册中心
|
|
72
|
+
*/
|
|
73
|
+
declare class ObjectTypeRegistry {
|
|
74
|
+
private types;
|
|
75
|
+
private objectProviders;
|
|
76
|
+
register(type: ObjectType): void;
|
|
77
|
+
unregister(id: string): void;
|
|
78
|
+
get(id: string): ObjectType | undefined;
|
|
79
|
+
getAll(): ObjectType[];
|
|
80
|
+
getRelations(typeId: string): RelationDefinition[];
|
|
81
|
+
/**
|
|
82
|
+
* Get relations filtered by target type.
|
|
83
|
+
* Mirrors Java ObjectType.getRelations(String type).
|
|
84
|
+
*/
|
|
85
|
+
getRelationsForTarget(typeId: string, targetType: string): RelationDefinition[];
|
|
86
|
+
/** Register a RelationObjectProvider. */
|
|
87
|
+
registerProvider(provider: RelationObjectProvider): void;
|
|
88
|
+
/** Unregister a RelationObjectProvider. */
|
|
89
|
+
unregisterProvider(typeId: string): void;
|
|
90
|
+
/** Get a RelationObjectProvider by type id. */
|
|
91
|
+
getProvider(typeId: string): RelationObjectProvider | undefined;
|
|
92
|
+
/** Get all registered RelationObjectProviders. */
|
|
93
|
+
getAllProviders(): RelationObjectProvider[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface RelatedObject {
|
|
97
|
+
sourceType: string;
|
|
98
|
+
sourceId: string;
|
|
99
|
+
/** Composite key derived from sourceType + sourceId. Mirrors Java RelatedEntity.objectKey. */
|
|
100
|
+
sourceKey?: string;
|
|
101
|
+
relation: string;
|
|
102
|
+
targetType: string;
|
|
103
|
+
targetId: string;
|
|
104
|
+
/** Composite key derived from targetType + targetId. Mirrors Java RelatedEntity.relatedKey. */
|
|
105
|
+
targetKey?: string;
|
|
106
|
+
targetName?: string;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
createdAt: Date;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Generate a composite key from type + id segments.
|
|
112
|
+
* Mirrors Java RelatedEntity.generateKey() which uses MD5.
|
|
113
|
+
*/
|
|
114
|
+
declare function generateRelationKey(...segments: string[]): string;
|
|
115
|
+
/**
|
|
116
|
+
* 关系持久化存储接口
|
|
117
|
+
*/
|
|
118
|
+
interface RelationStore {
|
|
119
|
+
save(relation: RelatedObject): Promise<void>;
|
|
120
|
+
remove(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
121
|
+
findRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Find objects that relate TO the given target (reverse lookup).
|
|
124
|
+
* Mirrors Java DefaultRelationObject.relations(reverse=true).
|
|
125
|
+
*/
|
|
126
|
+
findReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
127
|
+
removeAll(sourceType: string, sourceId: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Remove relations by relation type and target.
|
|
130
|
+
* Mirrors Java RelationService.saveRelated() which deletes by objectKey + relatedType + relation.
|
|
131
|
+
*/
|
|
132
|
+
removeByRelation?(sourceType: string, sourceId: string, relation: string, targetType: string): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 内存关系存储(默认实现)
|
|
136
|
+
*/
|
|
137
|
+
declare class InMemoryRelationStore implements RelationStore {
|
|
138
|
+
private relations;
|
|
139
|
+
save(relation: RelatedObject): Promise<void>;
|
|
140
|
+
remove(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
141
|
+
findRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Reverse lookup — find all objects that point TO the given target.
|
|
144
|
+
* Mirrors Java DefaultRelationOperation with reverse=true.
|
|
145
|
+
*/
|
|
146
|
+
findReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
147
|
+
removeAll(sourceType: string, sourceId: string): Promise<void>;
|
|
148
|
+
removeByRelation(sourceType: string, sourceId: string, relation: string, targetType: string): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 关系服务 — CRUD 操作
|
|
152
|
+
* Mirrors Java RelationService with forward and reverse relation support.
|
|
153
|
+
*/
|
|
154
|
+
declare class RelationService {
|
|
155
|
+
private readonly store;
|
|
156
|
+
private readonly logger;
|
|
157
|
+
constructor(store: RelationStore);
|
|
158
|
+
/**
|
|
159
|
+
* 绑定关系
|
|
160
|
+
*/
|
|
161
|
+
bind(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string, metadata?: Record<string, unknown>, targetName?: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* 获取相关对象(正向查询)
|
|
164
|
+
*/
|
|
165
|
+
getRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
166
|
+
/**
|
|
167
|
+
* 获取反向相关对象 — 谁指向了我?
|
|
168
|
+
* Mirrors Java RelationObject.relations(reverse=true).
|
|
169
|
+
*/
|
|
170
|
+
getReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
171
|
+
/**
|
|
172
|
+
* 解绑关系
|
|
173
|
+
*/
|
|
174
|
+
unbind(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* 移除源对象的所有关系
|
|
177
|
+
*/
|
|
178
|
+
unbindAll(sourceType: string, sourceId: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* 批量保存关系 — 替换指定 source + relation + targetType 下的所有关系。
|
|
181
|
+
* Mirrors Java RelationService.saveRelated().
|
|
182
|
+
*/
|
|
183
|
+
saveRelated(sourceType: string, sourceId: string, relation: string, targetType: string, targets: Array<{
|
|
184
|
+
id: string;
|
|
185
|
+
name?: string;
|
|
186
|
+
}>): Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare const RELATION_STORE: unique symbol;
|
|
190
|
+
declare class ZuckerRelationModule {
|
|
191
|
+
static forRoot(store?: RelationStore): DynamicModule;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { CompositeObjectType, InMemoryRelationStore, OBJECT_TYPE_IDS, type ObjectType, ObjectTypeRegistry, type PropertyDefinition, RELATION_STORE, type RelatedObject, type RelationDefinition, type RelationDirection, type RelationObjectProvider, RelationService, type RelationStore, type RelationType, ZuckerRelationModule, generateRelationKey };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
interface PropertyDefinition {
|
|
4
|
+
key: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
}
|
|
9
|
+
type RelationType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
10
|
+
type RelationDirection = 'forward' | 'reverse' | 'bidirectional';
|
|
11
|
+
interface RelationDefinition {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
targetType: string;
|
|
15
|
+
relationType: RelationType;
|
|
16
|
+
direction: RelationDirection;
|
|
17
|
+
/** Extra metadata. Mirrors Java Relation.expands. */
|
|
18
|
+
expands?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Object type definition.
|
|
22
|
+
* Mirrors Java ObjectType with description, expands, and relatedTypes.
|
|
23
|
+
*/
|
|
24
|
+
interface ObjectType {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
/** Description of the object type. Mirrors Java ObjectType.getDescription(). */
|
|
28
|
+
description?: string;
|
|
29
|
+
properties: PropertyDefinition[];
|
|
30
|
+
relations: RelationDefinition[];
|
|
31
|
+
/** Related object types. Mirrors Java ObjectType.getRelatedTypes(). */
|
|
32
|
+
relatedTypes?: ObjectType[];
|
|
33
|
+
/** Extension metadata. Mirrors Java ObjectType.getExpands(). */
|
|
34
|
+
expands?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Composite object type — merges two ObjectTypes, with main taking precedence
|
|
38
|
+
* for scalar fields and both contributing to list fields.
|
|
39
|
+
* Mirrors Java CompositeObjectType.
|
|
40
|
+
*/
|
|
41
|
+
declare class CompositeObjectType implements ObjectType {
|
|
42
|
+
private readonly main;
|
|
43
|
+
private readonly second;
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly description?: string;
|
|
47
|
+
readonly expands?: Record<string, unknown>;
|
|
48
|
+
constructor(main: ObjectType, second: ObjectType);
|
|
49
|
+
get properties(): PropertyDefinition[];
|
|
50
|
+
get relations(): RelationDefinition[];
|
|
51
|
+
get relatedTypes(): ObjectType[];
|
|
52
|
+
}
|
|
53
|
+
/** Well-known object type ids. Mirrors Java RelationObjectProvider constants. */
|
|
54
|
+
declare const OBJECT_TYPE_IDS: {
|
|
55
|
+
readonly USER: "user";
|
|
56
|
+
readonly DEVICE: "device";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Relation object provider SPI.
|
|
60
|
+
* Mirrors Java RelationObjectProvider interface.
|
|
61
|
+
*/
|
|
62
|
+
interface RelationObjectProvider {
|
|
63
|
+
/** The object type id this provider handles. */
|
|
64
|
+
getTypeId(): string;
|
|
65
|
+
/** Get the full ObjectType definition. */
|
|
66
|
+
getType(): Promise<ObjectType>;
|
|
67
|
+
/** Get property values for a specific object instance. */
|
|
68
|
+
getProperties?(id: string): Promise<Record<string, unknown>>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 对象类型注册中心
|
|
72
|
+
*/
|
|
73
|
+
declare class ObjectTypeRegistry {
|
|
74
|
+
private types;
|
|
75
|
+
private objectProviders;
|
|
76
|
+
register(type: ObjectType): void;
|
|
77
|
+
unregister(id: string): void;
|
|
78
|
+
get(id: string): ObjectType | undefined;
|
|
79
|
+
getAll(): ObjectType[];
|
|
80
|
+
getRelations(typeId: string): RelationDefinition[];
|
|
81
|
+
/**
|
|
82
|
+
* Get relations filtered by target type.
|
|
83
|
+
* Mirrors Java ObjectType.getRelations(String type).
|
|
84
|
+
*/
|
|
85
|
+
getRelationsForTarget(typeId: string, targetType: string): RelationDefinition[];
|
|
86
|
+
/** Register a RelationObjectProvider. */
|
|
87
|
+
registerProvider(provider: RelationObjectProvider): void;
|
|
88
|
+
/** Unregister a RelationObjectProvider. */
|
|
89
|
+
unregisterProvider(typeId: string): void;
|
|
90
|
+
/** Get a RelationObjectProvider by type id. */
|
|
91
|
+
getProvider(typeId: string): RelationObjectProvider | undefined;
|
|
92
|
+
/** Get all registered RelationObjectProviders. */
|
|
93
|
+
getAllProviders(): RelationObjectProvider[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface RelatedObject {
|
|
97
|
+
sourceType: string;
|
|
98
|
+
sourceId: string;
|
|
99
|
+
/** Composite key derived from sourceType + sourceId. Mirrors Java RelatedEntity.objectKey. */
|
|
100
|
+
sourceKey?: string;
|
|
101
|
+
relation: string;
|
|
102
|
+
targetType: string;
|
|
103
|
+
targetId: string;
|
|
104
|
+
/** Composite key derived from targetType + targetId. Mirrors Java RelatedEntity.relatedKey. */
|
|
105
|
+
targetKey?: string;
|
|
106
|
+
targetName?: string;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
createdAt: Date;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Generate a composite key from type + id segments.
|
|
112
|
+
* Mirrors Java RelatedEntity.generateKey() which uses MD5.
|
|
113
|
+
*/
|
|
114
|
+
declare function generateRelationKey(...segments: string[]): string;
|
|
115
|
+
/**
|
|
116
|
+
* 关系持久化存储接口
|
|
117
|
+
*/
|
|
118
|
+
interface RelationStore {
|
|
119
|
+
save(relation: RelatedObject): Promise<void>;
|
|
120
|
+
remove(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
121
|
+
findRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Find objects that relate TO the given target (reverse lookup).
|
|
124
|
+
* Mirrors Java DefaultRelationObject.relations(reverse=true).
|
|
125
|
+
*/
|
|
126
|
+
findReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
127
|
+
removeAll(sourceType: string, sourceId: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Remove relations by relation type and target.
|
|
130
|
+
* Mirrors Java RelationService.saveRelated() which deletes by objectKey + relatedType + relation.
|
|
131
|
+
*/
|
|
132
|
+
removeByRelation?(sourceType: string, sourceId: string, relation: string, targetType: string): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 内存关系存储(默认实现)
|
|
136
|
+
*/
|
|
137
|
+
declare class InMemoryRelationStore implements RelationStore {
|
|
138
|
+
private relations;
|
|
139
|
+
save(relation: RelatedObject): Promise<void>;
|
|
140
|
+
remove(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
141
|
+
findRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Reverse lookup — find all objects that point TO the given target.
|
|
144
|
+
* Mirrors Java DefaultRelationOperation with reverse=true.
|
|
145
|
+
*/
|
|
146
|
+
findReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
147
|
+
removeAll(sourceType: string, sourceId: string): Promise<void>;
|
|
148
|
+
removeByRelation(sourceType: string, sourceId: string, relation: string, targetType: string): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 关系服务 — CRUD 操作
|
|
152
|
+
* Mirrors Java RelationService with forward and reverse relation support.
|
|
153
|
+
*/
|
|
154
|
+
declare class RelationService {
|
|
155
|
+
private readonly store;
|
|
156
|
+
private readonly logger;
|
|
157
|
+
constructor(store: RelationStore);
|
|
158
|
+
/**
|
|
159
|
+
* 绑定关系
|
|
160
|
+
*/
|
|
161
|
+
bind(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string, metadata?: Record<string, unknown>, targetName?: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* 获取相关对象(正向查询)
|
|
164
|
+
*/
|
|
165
|
+
getRelated(sourceType: string, sourceId: string, relation?: string): Promise<RelatedObject[]>;
|
|
166
|
+
/**
|
|
167
|
+
* 获取反向相关对象 — 谁指向了我?
|
|
168
|
+
* Mirrors Java RelationObject.relations(reverse=true).
|
|
169
|
+
*/
|
|
170
|
+
getReverseRelated(targetType: string, targetId: string, relation?: string): Promise<RelatedObject[]>;
|
|
171
|
+
/**
|
|
172
|
+
* 解绑关系
|
|
173
|
+
*/
|
|
174
|
+
unbind(sourceType: string, sourceId: string, relation: string, targetType: string, targetId: string): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* 移除源对象的所有关系
|
|
177
|
+
*/
|
|
178
|
+
unbindAll(sourceType: string, sourceId: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* 批量保存关系 — 替换指定 source + relation + targetType 下的所有关系。
|
|
181
|
+
* Mirrors Java RelationService.saveRelated().
|
|
182
|
+
*/
|
|
183
|
+
saveRelated(sourceType: string, sourceId: string, relation: string, targetType: string, targets: Array<{
|
|
184
|
+
id: string;
|
|
185
|
+
name?: string;
|
|
186
|
+
}>): Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare const RELATION_STORE: unique symbol;
|
|
190
|
+
declare class ZuckerRelationModule {
|
|
191
|
+
static forRoot(store?: RelationStore): DynamicModule;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { CompositeObjectType, InMemoryRelationStore, OBJECT_TYPE_IDS, type ObjectType, ObjectTypeRegistry, type PropertyDefinition, RELATION_STORE, type RelatedObject, type RelationDefinition, type RelationDirection, type RelationObjectProvider, RelationService, type RelationStore, type RelationType, ZuckerRelationModule, generateRelationKey };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
CompositeObjectType: () => CompositeObjectType,
|
|
25
|
+
InMemoryRelationStore: () => InMemoryRelationStore,
|
|
26
|
+
OBJECT_TYPE_IDS: () => OBJECT_TYPE_IDS,
|
|
27
|
+
ObjectTypeRegistry: () => ObjectTypeRegistry,
|
|
28
|
+
RELATION_STORE: () => RELATION_STORE,
|
|
29
|
+
RelationService: () => RelationService,
|
|
30
|
+
ZuckerRelationModule: () => ZuckerRelationModule,
|
|
31
|
+
generateRelationKey: () => generateRelationKey
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/object-type.ts
|
|
36
|
+
var CompositeObjectType = class {
|
|
37
|
+
static {
|
|
38
|
+
__name(this, "CompositeObjectType");
|
|
39
|
+
}
|
|
40
|
+
main;
|
|
41
|
+
second;
|
|
42
|
+
id;
|
|
43
|
+
name;
|
|
44
|
+
description;
|
|
45
|
+
expands;
|
|
46
|
+
constructor(main, second) {
|
|
47
|
+
this.main = main;
|
|
48
|
+
this.second = second;
|
|
49
|
+
this.id = main.id;
|
|
50
|
+
this.name = main.name;
|
|
51
|
+
this.description = main.description ?? second.description;
|
|
52
|
+
this.expands = {
|
|
53
|
+
...second.expands ?? {},
|
|
54
|
+
...main.expands ?? {}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
get properties() {
|
|
58
|
+
return [
|
|
59
|
+
...this.main.properties ?? [],
|
|
60
|
+
...this.second.properties ?? []
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
get relations() {
|
|
64
|
+
return [
|
|
65
|
+
...this.main.relations ?? [],
|
|
66
|
+
...this.second.relations ?? []
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
get relatedTypes() {
|
|
70
|
+
return [
|
|
71
|
+
...this.main.relatedTypes ?? [],
|
|
72
|
+
...this.second.relatedTypes ?? []
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var OBJECT_TYPE_IDS = {
|
|
77
|
+
USER: "user",
|
|
78
|
+
DEVICE: "device"
|
|
79
|
+
};
|
|
80
|
+
var ObjectTypeRegistry = class {
|
|
81
|
+
static {
|
|
82
|
+
__name(this, "ObjectTypeRegistry");
|
|
83
|
+
}
|
|
84
|
+
types = /* @__PURE__ */ new Map();
|
|
85
|
+
objectProviders = /* @__PURE__ */ new Map();
|
|
86
|
+
register(type) {
|
|
87
|
+
this.types.set(type.id, type);
|
|
88
|
+
}
|
|
89
|
+
unregister(id) {
|
|
90
|
+
this.types.delete(id);
|
|
91
|
+
}
|
|
92
|
+
get(id) {
|
|
93
|
+
return this.types.get(id);
|
|
94
|
+
}
|
|
95
|
+
getAll() {
|
|
96
|
+
return Array.from(this.types.values());
|
|
97
|
+
}
|
|
98
|
+
getRelations(typeId) {
|
|
99
|
+
return this.types.get(typeId)?.relations ?? [];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get relations filtered by target type.
|
|
103
|
+
* Mirrors Java ObjectType.getRelations(String type).
|
|
104
|
+
*/
|
|
105
|
+
getRelationsForTarget(typeId, targetType) {
|
|
106
|
+
return this.getRelations(typeId).filter((r) => r.targetType === targetType);
|
|
107
|
+
}
|
|
108
|
+
/** Register a RelationObjectProvider. */
|
|
109
|
+
registerProvider(provider) {
|
|
110
|
+
this.objectProviders.set(provider.getTypeId(), provider);
|
|
111
|
+
}
|
|
112
|
+
/** Unregister a RelationObjectProvider. */
|
|
113
|
+
unregisterProvider(typeId) {
|
|
114
|
+
this.objectProviders.delete(typeId);
|
|
115
|
+
}
|
|
116
|
+
/** Get a RelationObjectProvider by type id. */
|
|
117
|
+
getProvider(typeId) {
|
|
118
|
+
return this.objectProviders.get(typeId);
|
|
119
|
+
}
|
|
120
|
+
/** Get all registered RelationObjectProviders. */
|
|
121
|
+
getAllProviders() {
|
|
122
|
+
return Array.from(this.objectProviders.values());
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/relation.service.ts
|
|
127
|
+
var import_common = require("@nestjs/common");
|
|
128
|
+
var import_node_crypto = require("crypto");
|
|
129
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
130
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
131
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
132
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
133
|
+
} else {
|
|
134
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
135
|
+
if (d = decorators[i]) {
|
|
136
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
141
|
+
}
|
|
142
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
143
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
144
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
145
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
149
|
+
function generateRelationKey(...segments) {
|
|
150
|
+
return (0, import_node_crypto.createHash)("md5").update(segments.join("|")).digest("hex");
|
|
151
|
+
}
|
|
152
|
+
__name(generateRelationKey, "generateRelationKey");
|
|
153
|
+
var InMemoryRelationStore = class {
|
|
154
|
+
static {
|
|
155
|
+
__name(this, "InMemoryRelationStore");
|
|
156
|
+
}
|
|
157
|
+
relations = [];
|
|
158
|
+
async save(relation) {
|
|
159
|
+
if (!relation.sourceKey) {
|
|
160
|
+
relation.sourceKey = generateRelationKey(relation.sourceType, relation.sourceId);
|
|
161
|
+
}
|
|
162
|
+
if (!relation.targetKey) {
|
|
163
|
+
relation.targetKey = generateRelationKey(relation.targetType, relation.targetId);
|
|
164
|
+
}
|
|
165
|
+
const existing = this.relations.findIndex((r) => r.sourceType === relation.sourceType && r.sourceId === relation.sourceId && r.relation === relation.relation && r.targetType === relation.targetType && r.targetId === relation.targetId);
|
|
166
|
+
if (existing >= 0) {
|
|
167
|
+
this.relations[existing] = relation;
|
|
168
|
+
} else {
|
|
169
|
+
this.relations.push(relation);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async remove(sourceType, sourceId, relation, targetType, targetId) {
|
|
173
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId && r.relation === relation && r.targetType === targetType && r.targetId === targetId));
|
|
174
|
+
}
|
|
175
|
+
async findRelated(sourceType, sourceId, relation) {
|
|
176
|
+
return this.relations.filter((r) => r.sourceType === sourceType && r.sourceId === sourceId && (!relation || r.relation === relation));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Reverse lookup — find all objects that point TO the given target.
|
|
180
|
+
* Mirrors Java DefaultRelationOperation with reverse=true.
|
|
181
|
+
*/
|
|
182
|
+
async findReverseRelated(targetType, targetId, relation) {
|
|
183
|
+
return this.relations.filter((r) => r.targetType === targetType && r.targetId === targetId && (!relation || r.relation === relation));
|
|
184
|
+
}
|
|
185
|
+
async removeAll(sourceType, sourceId) {
|
|
186
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId));
|
|
187
|
+
}
|
|
188
|
+
async removeByRelation(sourceType, sourceId, relation, targetType) {
|
|
189
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId && r.relation === relation && r.targetType === targetType));
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var RelationService = class _RelationService {
|
|
193
|
+
static {
|
|
194
|
+
__name(this, "RelationService");
|
|
195
|
+
}
|
|
196
|
+
store;
|
|
197
|
+
logger = new import_common.Logger(_RelationService.name);
|
|
198
|
+
constructor(store) {
|
|
199
|
+
this.store = store;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 绑定关系
|
|
203
|
+
*/
|
|
204
|
+
async bind(sourceType, sourceId, relation, targetType, targetId, metadata, targetName) {
|
|
205
|
+
await this.store.save({
|
|
206
|
+
sourceType,
|
|
207
|
+
sourceId,
|
|
208
|
+
sourceKey: generateRelationKey(sourceType, sourceId),
|
|
209
|
+
relation,
|
|
210
|
+
targetType,
|
|
211
|
+
targetId,
|
|
212
|
+
targetKey: generateRelationKey(targetType, targetId),
|
|
213
|
+
targetName,
|
|
214
|
+
metadata,
|
|
215
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
216
|
+
});
|
|
217
|
+
this.logger.debug(`Relation bound: ${sourceType}:${sourceId} -[${relation}]-> ${targetType}:${targetId}`);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* 获取相关对象(正向查询)
|
|
221
|
+
*/
|
|
222
|
+
async getRelated(sourceType, sourceId, relation) {
|
|
223
|
+
return this.store.findRelated(sourceType, sourceId, relation);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* 获取反向相关对象 — 谁指向了我?
|
|
227
|
+
* Mirrors Java RelationObject.relations(reverse=true).
|
|
228
|
+
*/
|
|
229
|
+
async getReverseRelated(targetType, targetId, relation) {
|
|
230
|
+
return this.store.findReverseRelated(targetType, targetId, relation);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 解绑关系
|
|
234
|
+
*/
|
|
235
|
+
async unbind(sourceType, sourceId, relation, targetType, targetId) {
|
|
236
|
+
await this.store.remove(sourceType, sourceId, relation, targetType, targetId);
|
|
237
|
+
this.logger.debug(`Relation unbound: ${sourceType}:${sourceId} -[${relation}]-> ${targetType}:${targetId}`);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 移除源对象的所有关系
|
|
241
|
+
*/
|
|
242
|
+
async unbindAll(sourceType, sourceId) {
|
|
243
|
+
await this.store.removeAll(sourceType, sourceId);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* 批量保存关系 — 替换指定 source + relation + targetType 下的所有关系。
|
|
247
|
+
* Mirrors Java RelationService.saveRelated().
|
|
248
|
+
*/
|
|
249
|
+
async saveRelated(sourceType, sourceId, relation, targetType, targets) {
|
|
250
|
+
if (this.store.removeByRelation) {
|
|
251
|
+
await this.store.removeByRelation(sourceType, sourceId, relation, targetType);
|
|
252
|
+
}
|
|
253
|
+
for (const target of targets) {
|
|
254
|
+
await this.bind(sourceType, sourceId, relation, targetType, target.id, void 0, target.name);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
RelationService = _ts_decorate([
|
|
259
|
+
(0, import_common.Injectable)(),
|
|
260
|
+
_ts_metadata("design:type", Function),
|
|
261
|
+
_ts_metadata("design:paramtypes", [
|
|
262
|
+
typeof RelationStore === "undefined" ? Object : RelationStore
|
|
263
|
+
])
|
|
264
|
+
], RelationService);
|
|
265
|
+
|
|
266
|
+
// src/relation.module.ts
|
|
267
|
+
var import_common2 = require("@nestjs/common");
|
|
268
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
269
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
270
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
271
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
272
|
+
} else {
|
|
273
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
274
|
+
if (d = decorators[i]) {
|
|
275
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
280
|
+
}
|
|
281
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
282
|
+
var RELATION_STORE = /* @__PURE__ */ Symbol("RELATION_STORE");
|
|
283
|
+
var ZuckerRelationModule = class _ZuckerRelationModule {
|
|
284
|
+
static {
|
|
285
|
+
__name(this, "ZuckerRelationModule");
|
|
286
|
+
}
|
|
287
|
+
static forRoot(store) {
|
|
288
|
+
const relationStore = store ?? new InMemoryRelationStore();
|
|
289
|
+
return {
|
|
290
|
+
module: _ZuckerRelationModule,
|
|
291
|
+
global: true,
|
|
292
|
+
providers: [
|
|
293
|
+
{
|
|
294
|
+
provide: RELATION_STORE,
|
|
295
|
+
useValue: relationStore
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
provide: RelationService,
|
|
299
|
+
useFactory: /* @__PURE__ */ __name(() => new RelationService(relationStore), "useFactory")
|
|
300
|
+
},
|
|
301
|
+
ObjectTypeRegistry
|
|
302
|
+
],
|
|
303
|
+
exports: [
|
|
304
|
+
RelationService,
|
|
305
|
+
ObjectTypeRegistry,
|
|
306
|
+
RELATION_STORE
|
|
307
|
+
]
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
ZuckerRelationModule = _ts_decorate2([
|
|
312
|
+
(0, import_common2.Global)(),
|
|
313
|
+
(0, import_common2.Module)({})
|
|
314
|
+
], ZuckerRelationModule);
|
|
315
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
316
|
+
0 && (module.exports = {
|
|
317
|
+
CompositeObjectType,
|
|
318
|
+
InMemoryRelationStore,
|
|
319
|
+
OBJECT_TYPE_IDS,
|
|
320
|
+
ObjectTypeRegistry,
|
|
321
|
+
RELATION_STORE,
|
|
322
|
+
RelationService,
|
|
323
|
+
ZuckerRelationModule,
|
|
324
|
+
generateRelationKey
|
|
325
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/object-type.ts
|
|
5
|
+
var CompositeObjectType = class {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "CompositeObjectType");
|
|
8
|
+
}
|
|
9
|
+
main;
|
|
10
|
+
second;
|
|
11
|
+
id;
|
|
12
|
+
name;
|
|
13
|
+
description;
|
|
14
|
+
expands;
|
|
15
|
+
constructor(main, second) {
|
|
16
|
+
this.main = main;
|
|
17
|
+
this.second = second;
|
|
18
|
+
this.id = main.id;
|
|
19
|
+
this.name = main.name;
|
|
20
|
+
this.description = main.description ?? second.description;
|
|
21
|
+
this.expands = {
|
|
22
|
+
...second.expands ?? {},
|
|
23
|
+
...main.expands ?? {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
get properties() {
|
|
27
|
+
return [
|
|
28
|
+
...this.main.properties ?? [],
|
|
29
|
+
...this.second.properties ?? []
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
get relations() {
|
|
33
|
+
return [
|
|
34
|
+
...this.main.relations ?? [],
|
|
35
|
+
...this.second.relations ?? []
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
get relatedTypes() {
|
|
39
|
+
return [
|
|
40
|
+
...this.main.relatedTypes ?? [],
|
|
41
|
+
...this.second.relatedTypes ?? []
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var OBJECT_TYPE_IDS = {
|
|
46
|
+
USER: "user",
|
|
47
|
+
DEVICE: "device"
|
|
48
|
+
};
|
|
49
|
+
var ObjectTypeRegistry = class {
|
|
50
|
+
static {
|
|
51
|
+
__name(this, "ObjectTypeRegistry");
|
|
52
|
+
}
|
|
53
|
+
types = /* @__PURE__ */ new Map();
|
|
54
|
+
objectProviders = /* @__PURE__ */ new Map();
|
|
55
|
+
register(type) {
|
|
56
|
+
this.types.set(type.id, type);
|
|
57
|
+
}
|
|
58
|
+
unregister(id) {
|
|
59
|
+
this.types.delete(id);
|
|
60
|
+
}
|
|
61
|
+
get(id) {
|
|
62
|
+
return this.types.get(id);
|
|
63
|
+
}
|
|
64
|
+
getAll() {
|
|
65
|
+
return Array.from(this.types.values());
|
|
66
|
+
}
|
|
67
|
+
getRelations(typeId) {
|
|
68
|
+
return this.types.get(typeId)?.relations ?? [];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get relations filtered by target type.
|
|
72
|
+
* Mirrors Java ObjectType.getRelations(String type).
|
|
73
|
+
*/
|
|
74
|
+
getRelationsForTarget(typeId, targetType) {
|
|
75
|
+
return this.getRelations(typeId).filter((r) => r.targetType === targetType);
|
|
76
|
+
}
|
|
77
|
+
/** Register a RelationObjectProvider. */
|
|
78
|
+
registerProvider(provider) {
|
|
79
|
+
this.objectProviders.set(provider.getTypeId(), provider);
|
|
80
|
+
}
|
|
81
|
+
/** Unregister a RelationObjectProvider. */
|
|
82
|
+
unregisterProvider(typeId) {
|
|
83
|
+
this.objectProviders.delete(typeId);
|
|
84
|
+
}
|
|
85
|
+
/** Get a RelationObjectProvider by type id. */
|
|
86
|
+
getProvider(typeId) {
|
|
87
|
+
return this.objectProviders.get(typeId);
|
|
88
|
+
}
|
|
89
|
+
/** Get all registered RelationObjectProviders. */
|
|
90
|
+
getAllProviders() {
|
|
91
|
+
return Array.from(this.objectProviders.values());
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/relation.service.ts
|
|
96
|
+
import { Injectable, Logger } from "@nestjs/common";
|
|
97
|
+
import { createHash } from "crypto";
|
|
98
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
99
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
100
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
101
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
102
|
+
} else {
|
|
103
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
104
|
+
if (d = decorators[i]) {
|
|
105
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
110
|
+
}
|
|
111
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
112
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
113
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
114
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
118
|
+
function generateRelationKey(...segments) {
|
|
119
|
+
return createHash("md5").update(segments.join("|")).digest("hex");
|
|
120
|
+
}
|
|
121
|
+
__name(generateRelationKey, "generateRelationKey");
|
|
122
|
+
var InMemoryRelationStore = class {
|
|
123
|
+
static {
|
|
124
|
+
__name(this, "InMemoryRelationStore");
|
|
125
|
+
}
|
|
126
|
+
relations = [];
|
|
127
|
+
async save(relation) {
|
|
128
|
+
if (!relation.sourceKey) {
|
|
129
|
+
relation.sourceKey = generateRelationKey(relation.sourceType, relation.sourceId);
|
|
130
|
+
}
|
|
131
|
+
if (!relation.targetKey) {
|
|
132
|
+
relation.targetKey = generateRelationKey(relation.targetType, relation.targetId);
|
|
133
|
+
}
|
|
134
|
+
const existing = this.relations.findIndex((r) => r.sourceType === relation.sourceType && r.sourceId === relation.sourceId && r.relation === relation.relation && r.targetType === relation.targetType && r.targetId === relation.targetId);
|
|
135
|
+
if (existing >= 0) {
|
|
136
|
+
this.relations[existing] = relation;
|
|
137
|
+
} else {
|
|
138
|
+
this.relations.push(relation);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async remove(sourceType, sourceId, relation, targetType, targetId) {
|
|
142
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId && r.relation === relation && r.targetType === targetType && r.targetId === targetId));
|
|
143
|
+
}
|
|
144
|
+
async findRelated(sourceType, sourceId, relation) {
|
|
145
|
+
return this.relations.filter((r) => r.sourceType === sourceType && r.sourceId === sourceId && (!relation || r.relation === relation));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Reverse lookup — find all objects that point TO the given target.
|
|
149
|
+
* Mirrors Java DefaultRelationOperation with reverse=true.
|
|
150
|
+
*/
|
|
151
|
+
async findReverseRelated(targetType, targetId, relation) {
|
|
152
|
+
return this.relations.filter((r) => r.targetType === targetType && r.targetId === targetId && (!relation || r.relation === relation));
|
|
153
|
+
}
|
|
154
|
+
async removeAll(sourceType, sourceId) {
|
|
155
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId));
|
|
156
|
+
}
|
|
157
|
+
async removeByRelation(sourceType, sourceId, relation, targetType) {
|
|
158
|
+
this.relations = this.relations.filter((r) => !(r.sourceType === sourceType && r.sourceId === sourceId && r.relation === relation && r.targetType === targetType));
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var RelationService = class _RelationService {
|
|
162
|
+
static {
|
|
163
|
+
__name(this, "RelationService");
|
|
164
|
+
}
|
|
165
|
+
store;
|
|
166
|
+
logger = new Logger(_RelationService.name);
|
|
167
|
+
constructor(store) {
|
|
168
|
+
this.store = store;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 绑定关系
|
|
172
|
+
*/
|
|
173
|
+
async bind(sourceType, sourceId, relation, targetType, targetId, metadata, targetName) {
|
|
174
|
+
await this.store.save({
|
|
175
|
+
sourceType,
|
|
176
|
+
sourceId,
|
|
177
|
+
sourceKey: generateRelationKey(sourceType, sourceId),
|
|
178
|
+
relation,
|
|
179
|
+
targetType,
|
|
180
|
+
targetId,
|
|
181
|
+
targetKey: generateRelationKey(targetType, targetId),
|
|
182
|
+
targetName,
|
|
183
|
+
metadata,
|
|
184
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
185
|
+
});
|
|
186
|
+
this.logger.debug(`Relation bound: ${sourceType}:${sourceId} -[${relation}]-> ${targetType}:${targetId}`);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 获取相关对象(正向查询)
|
|
190
|
+
*/
|
|
191
|
+
async getRelated(sourceType, sourceId, relation) {
|
|
192
|
+
return this.store.findRelated(sourceType, sourceId, relation);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 获取反向相关对象 — 谁指向了我?
|
|
196
|
+
* Mirrors Java RelationObject.relations(reverse=true).
|
|
197
|
+
*/
|
|
198
|
+
async getReverseRelated(targetType, targetId, relation) {
|
|
199
|
+
return this.store.findReverseRelated(targetType, targetId, relation);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 解绑关系
|
|
203
|
+
*/
|
|
204
|
+
async unbind(sourceType, sourceId, relation, targetType, targetId) {
|
|
205
|
+
await this.store.remove(sourceType, sourceId, relation, targetType, targetId);
|
|
206
|
+
this.logger.debug(`Relation unbound: ${sourceType}:${sourceId} -[${relation}]-> ${targetType}:${targetId}`);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 移除源对象的所有关系
|
|
210
|
+
*/
|
|
211
|
+
async unbindAll(sourceType, sourceId) {
|
|
212
|
+
await this.store.removeAll(sourceType, sourceId);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 批量保存关系 — 替换指定 source + relation + targetType 下的所有关系。
|
|
216
|
+
* Mirrors Java RelationService.saveRelated().
|
|
217
|
+
*/
|
|
218
|
+
async saveRelated(sourceType, sourceId, relation, targetType, targets) {
|
|
219
|
+
if (this.store.removeByRelation) {
|
|
220
|
+
await this.store.removeByRelation(sourceType, sourceId, relation, targetType);
|
|
221
|
+
}
|
|
222
|
+
for (const target of targets) {
|
|
223
|
+
await this.bind(sourceType, sourceId, relation, targetType, target.id, void 0, target.name);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
RelationService = _ts_decorate([
|
|
228
|
+
Injectable(),
|
|
229
|
+
_ts_metadata("design:type", Function),
|
|
230
|
+
_ts_metadata("design:paramtypes", [
|
|
231
|
+
typeof RelationStore === "undefined" ? Object : RelationStore
|
|
232
|
+
])
|
|
233
|
+
], RelationService);
|
|
234
|
+
|
|
235
|
+
// src/relation.module.ts
|
|
236
|
+
import { Module, Global } from "@nestjs/common";
|
|
237
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
238
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
239
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
240
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
241
|
+
} else {
|
|
242
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
243
|
+
if (d = decorators[i]) {
|
|
244
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
249
|
+
}
|
|
250
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
251
|
+
var RELATION_STORE = /* @__PURE__ */ Symbol("RELATION_STORE");
|
|
252
|
+
var ZuckerRelationModule = class _ZuckerRelationModule {
|
|
253
|
+
static {
|
|
254
|
+
__name(this, "ZuckerRelationModule");
|
|
255
|
+
}
|
|
256
|
+
static forRoot(store) {
|
|
257
|
+
const relationStore = store ?? new InMemoryRelationStore();
|
|
258
|
+
return {
|
|
259
|
+
module: _ZuckerRelationModule,
|
|
260
|
+
global: true,
|
|
261
|
+
providers: [
|
|
262
|
+
{
|
|
263
|
+
provide: RELATION_STORE,
|
|
264
|
+
useValue: relationStore
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
provide: RelationService,
|
|
268
|
+
useFactory: /* @__PURE__ */ __name(() => new RelationService(relationStore), "useFactory")
|
|
269
|
+
},
|
|
270
|
+
ObjectTypeRegistry
|
|
271
|
+
],
|
|
272
|
+
exports: [
|
|
273
|
+
RelationService,
|
|
274
|
+
ObjectTypeRegistry,
|
|
275
|
+
RELATION_STORE
|
|
276
|
+
]
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
ZuckerRelationModule = _ts_decorate2([
|
|
281
|
+
Global(),
|
|
282
|
+
Module({})
|
|
283
|
+
], ZuckerRelationModule);
|
|
284
|
+
export {
|
|
285
|
+
CompositeObjectType,
|
|
286
|
+
InMemoryRelationStore,
|
|
287
|
+
OBJECT_TYPE_IDS,
|
|
288
|
+
ObjectTypeRegistry,
|
|
289
|
+
RELATION_STORE,
|
|
290
|
+
RelationService,
|
|
291
|
+
ZuckerRelationModule,
|
|
292
|
+
generateRelationKey
|
|
293
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zucker-framework/relation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"NOTICE",
|
|
11
|
+
"THIRD_PARTY_NOTICES"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@zucker-framework/core": "1.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^20.19.43"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@nestjs/common": "^12.0.0",
|
|
21
|
+
"@nestjs/core": "^12.0.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": "Lind",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Lind-pro/zucker-framework.git",
|
|
28
|
+
"directory": "packages/relation"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"lint": "eslint src/"
|
|
38
|
+
}
|
|
39
|
+
}
|