rotorise 0.1.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/LICENCE +201 -0
- package/README.md +15 -0
- package/dist/Rotorise.d.ts +69 -0
- package/dist/Rotorise.d.ts.map +1 -0
- package/dist/Rotorise.js +77 -0
- package/dist/Rotorise.js.map +1 -0
- package/dist/typeUtils.d.ts +23 -0
- package/dist/typeUtils.d.ts.map +1 -0
- package/dist/typeUtils.js +3 -0
- package/dist/typeUtils.js.map +1 -0
- package/package.json +39 -0
package/LICENCE
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/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Rotorise
|
|
2
|
+
|
|
3
|
+
Supercharge your DynamoDB with DynamoDB Rotorise!
|
|
4
|
+
|
|
5
|
+
DynamoDB offers incredible flexibility, but managing advanced patterns and techniques can be a challenge. [Rotorise](https://github.com/josher8a/Rotorise) simplifies complex operations by providing abstractions for key definitions, composite key constructors, partial composite keys, and advanced sort key usage in queries. It integrates seamlessly with the [Brushless](https://github.com/josher8a/Brushless) for a frictionless and performant DynamoDB experience.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install rotorise
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Contributing
|
|
15
|
+
Open an [issue](https://github.com/josher8a/Rotorise/issues) or a PR. We are open to any kind of contribution and feedback.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { DistributiveOmit, DistributivePick, Pretty, SliceFromStart, ValueOf } from './typeUtils';
|
|
2
|
+
import type { Exact } from 'type-fest';
|
|
3
|
+
export type Slices<rest extends unknown[], minLength extends number = 0, slice extends unknown[] = [], passedSkip extends 1 | 0 = slice['length'] extends minLength ? 1 : 0> = (passedSkip extends 1 ? slice : never) | (rest extends [infer h, ...infer R] ? Slices<R, minLength, [
|
|
4
|
+
...slice,
|
|
5
|
+
h
|
|
6
|
+
], [
|
|
7
|
+
...slice,
|
|
8
|
+
h
|
|
9
|
+
]['length'] extends minLength ? 1 : passedSkip> : never);
|
|
10
|
+
export type CompositeKeyParams<Entity extends Record<string, unknown>, Spec extends InputSpec<Entity>[], skip extends number = 1, P extends InputSpec<Entity>[] = Slices<Spec, skip>> = Entity extends unknown ? P extends unknown ? Pretty<{
|
|
11
|
+
[K in extractHeadOrPass<P[number]> & string]: Entity[K];
|
|
12
|
+
} & {
|
|
13
|
+
[K in extractHeadOrPass<Exclude<Spec[number], P[number]>>]?: undefined;
|
|
14
|
+
}> : never : never;
|
|
15
|
+
export type CompositeKeyBuilder<Entity extends Record<string, unknown>, Spec extends InputSpec<Entity>[], Delimiter extends string = '#', Deep extends number = Spec['length'], isPartial extends boolean = false> = Entity extends unknown ? CompositeKeyBuilderImpl<Entity, SliceFromStart<Spec, Deep>> extends infer Values extends joinablePair[] ? Join<isPartial extends false ? Values : Slices<Values>, Delimiter> : never : never;
|
|
16
|
+
type joinable = string | number | bigint | boolean | null | undefined;
|
|
17
|
+
type joinablePair = [joinable, joinable];
|
|
18
|
+
export type Join<Pairs extends joinablePair[], Delimiter extends string> = Pairs extends [joinablePair] ? `${Pairs[0][0]}${Delimiter}${Pairs[0][1]}` : Pairs extends [joinablePair, ...infer Tail extends joinablePair[]] ? `${Pairs[0][0]}${Delimiter}${Pairs[0][1]}${Delimiter}${Join<Tail, Delimiter>}` : never;
|
|
19
|
+
type CompositeKeyBuilderImpl<Entity extends Record<string, unknown>, Spec extends InputSpec<Entity>[], Pairs extends joinablePair[] = []> = Spec extends [infer F, ...infer R extends InputSpec<Entity>[]] ? F extends keyof Entity & string ? Entity[F] extends joinable ? CompositeKeyBuilderImpl<Entity, R, [
|
|
20
|
+
...Pairs,
|
|
21
|
+
[Uppercase<F>, Entity[F]]
|
|
22
|
+
]> : never : F extends [keyof Entity & string, (...x: (infer _)[]) => infer Tr] ? Tr extends joinable ? CompositeKeyBuilderImpl<Entity, R, [
|
|
23
|
+
...Pairs,
|
|
24
|
+
[Uppercase<F[0]>, Tr]
|
|
25
|
+
]> : never : never : Pairs;
|
|
26
|
+
export type TableEntry<Schema extends Record<string, InputSpec<Entity>[] | keyof Entity>, Entity extends Record<string, unknown>, Delimiter extends string = '#'> = Entity extends unknown ? Entity & {
|
|
27
|
+
[K in keyof Schema]: Schema[K] extends InputSpec<Entity>[] ? CompositeKeyBuilder<Entity, Schema[K], Delimiter> : Entity[Schema[K] & keyof Entity];
|
|
28
|
+
} : never;
|
|
29
|
+
export type InterfaceWithInjection<I, D> = {
|
|
30
|
+
[K in keyof I]: (dep: D) => I[K];
|
|
31
|
+
};
|
|
32
|
+
export declare const chainableNoOpProxy: unknown;
|
|
33
|
+
export declare const createPathProxy: <T>(path?: string) => T;
|
|
34
|
+
type Unionize<T extends object> = {
|
|
35
|
+
[k in keyof T]: {
|
|
36
|
+
k: k;
|
|
37
|
+
v: T[k];
|
|
38
|
+
};
|
|
39
|
+
}[keyof T];
|
|
40
|
+
type KVPair = {
|
|
41
|
+
k: PropertyKey;
|
|
42
|
+
v: unknown;
|
|
43
|
+
};
|
|
44
|
+
type InputSpec<Entity extends Record<string, unknown>, KV extends KVPair = Unionize<Entity>> = Pretty<{
|
|
45
|
+
[key in keyof Entity]: [key, (key: Extract<KV, {
|
|
46
|
+
k: key;
|
|
47
|
+
}>['v']) => unknown] | key;
|
|
48
|
+
}[keyof Entity]>;
|
|
49
|
+
type extractHeadOrPass<T extends [PropertyKey, unknown] | PropertyKey> = T extends [infer Head, ...infer _] ? Head : T;
|
|
50
|
+
export type keysWithNumericValue<Entity extends object, KVs extends KVPair = Unionize<Entity>, K_wNumber extends PropertyKey = Extract<KVs, {
|
|
51
|
+
v: number;
|
|
52
|
+
}>['k'], K_woNumber extends PropertyKey = Exclude<KVs, {
|
|
53
|
+
k: K_wNumber;
|
|
54
|
+
v: number;
|
|
55
|
+
}>['k']> = Exclude<K_wNumber, K_woNumber>;
|
|
56
|
+
type FullKeySpec<Entity extends Record<string, unknown>> = InputSpec<Entity>[] | (keysWithNumericValue<Entity> & keyof Entity);
|
|
57
|
+
type TableEntryDefinition<Entity extends Record<string, unknown>, Schema extends Record<string, FullKeySpec<Entity>>, Separator extends string = '#'> = {
|
|
58
|
+
toEntry: <const ExactEntity extends Exact<Entity, ExactEntity>>(item: ExactEntity) => ExactEntity extends infer E extends Entity ? Schema extends Record<string, FullKeySpec<E>> ? TableEntry<Schema, E, Separator> : never : never;
|
|
59
|
+
fromEntry: <const Entry extends TableEntry<Schema, Entity, Separator>>(entry: Entry) => DistributiveOmit<Entry, keyof Schema>;
|
|
60
|
+
key: <const Key extends keyof Schema, const Config extends Schema[Key] extends unknown[] ? {
|
|
61
|
+
depth?: number;
|
|
62
|
+
allowPartial?: boolean;
|
|
63
|
+
} : never, const Attributes extends Schema[Key] extends keyof Entity ? DistributivePick<Entity, Schema[Key] & keyof Entity> : Config['allowPartial'] extends true ? CompositeKeyParams<Entity, Schema[Key]> : DistributivePick<Entity, extractHeadOrPass<Pretty<SliceFromStart<Schema[Key], Exclude<Config['depth'], undefined>>[number]>>>>(key: Key, attributes: Attributes, config?: Config | undefined) => Schema[Key] extends InputSpec<Entity>[] ? CompositeKeyBuilder<Entity & Attributes, Schema[Key] extends FullKeySpec<Entity & Attributes> ? Schema[Key] : never, Separator, Exclude<Config['depth'], undefined>, Exclude<Config['allowPartial'], undefined>> : ValueOf<Attributes>;
|
|
64
|
+
infer: TableEntry<Schema, Entity, Separator>;
|
|
65
|
+
path: () => TableEntry<Schema, Entity, Separator>;
|
|
66
|
+
};
|
|
67
|
+
export declare const tableEntry: <const Entity extends Record<string, unknown>>() => <const Schema extends Record<string, FullKeySpec<Entity>>, Separator extends string = "#">(schema: Schema, separator?: Separator) => TableEntryDefinition<Entity, Schema, Separator>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=Rotorise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rotorise.d.ts","sourceRoot":"","sources":["../src/Rotorise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,OAAO,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,MAAM,MAAM,CACd,IAAI,SAAS,OAAO,EAAE,EACtB,SAAS,SAAS,MAAM,GAAG,CAAC,EAC5B,KAAK,SAAS,OAAO,EAAE,GAAG,EAAE,EAC5B,UAAU,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,IAElE,CAAC,UAAU,SAAS,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,GACtC,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAC7B,MAAM,CACF,CAAC,EACD,SAAS,EACT;IAAC,GAAG,KAAK;IAAE,CAAC;CAAC,EACb;IAAC,GAAG,KAAK;IAAE,CAAC;CAAC,CAAC,QAAQ,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,UAAU,CAC7D,GACD,KAAK,CAAC,CAAA;AAElB,MAAM,MAAM,kBAAkB,CAC1B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,IAAI,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,EAChC,IAAI,SAAS,MAAM,GAAG,CAAC,E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S,CAAC,MAAM,CAAC,EAAE,GACtC,mBAAmB,CACf,MAAM,GAAG,UAAU,EACnB,MAAM,CAAC,GAAG,CAAC,SAAS,WAAW,CAAC,MAAM,GAAG,UAAU,CAAC,GAC9C,MAAM,CAAC,GAAG,CAAC,GACX,KAAK,EACX,SAAS,EACT,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,EACnC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAC7C,GACD,OAAO,CAAC,UAAU,CAAC,CAAA;IAEzB,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5C,IAAI,EAAE,MAAM,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;CACpD,CAAA;AAED,eAAO,MAAM,UAAU,yJAMP,MAAM,cACH,SAAS,KACpB,qBAAsB,MAAM,EAAE,MAAM,EAAE,SAAS,CASlD,CAAA"}
|
package/dist/Rotorise.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableEntry = exports.createPathProxy = exports.chainableNoOpProxy = void 0;
|
|
4
|
+
exports.chainableNoOpProxy = new Proxy(() => exports.chainableNoOpProxy, {
|
|
5
|
+
get: () => exports.chainableNoOpProxy,
|
|
6
|
+
});
|
|
7
|
+
const createPathProxy = (path = '') => {
|
|
8
|
+
return new Proxy(() => { }, {
|
|
9
|
+
get: (target, prop, receiver) => {
|
|
10
|
+
if (typeof prop === 'string') {
|
|
11
|
+
if (prop === 'toString') {
|
|
12
|
+
return () => path;
|
|
13
|
+
}
|
|
14
|
+
return (0, exports.createPathProxy)(path === ''
|
|
15
|
+
? prop
|
|
16
|
+
: !Number.isNaN(Number.parseInt(prop))
|
|
17
|
+
? `${path}[${prop}]`
|
|
18
|
+
: `${path}.${prop}`);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.createPathProxy = createPathProxy;
|
|
24
|
+
const key = () => (schema, separator = '#') => (key, attributes, config) => {
|
|
25
|
+
let structure = schema[key] ?? [];
|
|
26
|
+
if (!Array.isArray(structure)) {
|
|
27
|
+
return attributes[structure];
|
|
28
|
+
}
|
|
29
|
+
if (config?.depth !== undefined) {
|
|
30
|
+
structure = structure.slice(0, config.depth);
|
|
31
|
+
}
|
|
32
|
+
const composite = [];
|
|
33
|
+
for (const keySpec of structure) {
|
|
34
|
+
const [key, transform] = Array.isArray(keySpec)
|
|
35
|
+
? keySpec
|
|
36
|
+
: [keySpec];
|
|
37
|
+
const value = attributes[key];
|
|
38
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
39
|
+
composite.push(key.toString().toUpperCase());
|
|
40
|
+
composite.push(`${transform ? transform(value) : value}`);
|
|
41
|
+
}
|
|
42
|
+
else if (config?.allowPartial) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(`buildCompositeKey: Attribute ${key.toString()} not found in ${attributes}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return composite.join(separator);
|
|
50
|
+
};
|
|
51
|
+
const toEntry = () => (schema, separator = '#') => (item) => {
|
|
52
|
+
const entry = { ...item };
|
|
53
|
+
for (const key_ in schema) {
|
|
54
|
+
entry[key_] = key()(schema, separator)(key_, item);
|
|
55
|
+
}
|
|
56
|
+
// console.log({ entry })
|
|
57
|
+
return entry;
|
|
58
|
+
};
|
|
59
|
+
const fromEntry = () => (schema, separator = '#') => (entry) => {
|
|
60
|
+
const item = { ...entry };
|
|
61
|
+
for (const key_ in schema) {
|
|
62
|
+
delete item[key_];
|
|
63
|
+
}
|
|
64
|
+
// console.log({ item })
|
|
65
|
+
return item;
|
|
66
|
+
};
|
|
67
|
+
const tableEntry = () => (schema, separator = '#') => {
|
|
68
|
+
return {
|
|
69
|
+
toEntry: toEntry()(schema, separator),
|
|
70
|
+
fromEntry: fromEntry()(schema, separator),
|
|
71
|
+
key: key()(schema, separator),
|
|
72
|
+
infer: exports.chainableNoOpProxy,
|
|
73
|
+
path: () => (0, exports.createPathProxy)(),
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
exports.tableEntry = tableEntry;
|
|
77
|
+
//# sourceMappingURL=Rotorise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rotorise.js","sourceRoot":"","sources":["../src/Rotorise.ts"],"names":[],"mappings":";;;AAkHa,QAAA,kBAAkB,GAAY,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC,0BAAkB,EAAE;IAC3E,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAkB;CAChC,CAAC,CAAA;AAEK,MAAM,eAAe,GAAG,CAAI,IAAI,GAAG,EAAE,EAAK,EAAE;IAC/C,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE;QACvB,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC3B,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;oBACtB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA;gBACrB,CAAC;gBAED,OAAO,IAAA,uBAAe,EAClB,IAAI,KAAK,EAAE;oBACP,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBACpC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG;wBACpB,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAC5B,CAAA;YACL,CAAC;QACL,CAAC;KACJ,CAAM,CAAA;AACX,CAAC,CAAA;AAlBY,QAAA,eAAe,mBAkB3B;AAmCD,MAAM,GAAG,GACL,GAAiD,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|
|
2
|
+
export type Pretty<T> = T extends unknown ? {
|
|
3
|
+
[K in keyof T]: T[K];
|
|
4
|
+
} & unknown : never;
|
|
5
|
+
export type PrettyDeep<T> = T extends unknown ? {
|
|
6
|
+
[K in keyof T]: T[K] extends Record<string, unknown> ? PrettyDeep<T[K]> : T[K];
|
|
7
|
+
} : never;
|
|
8
|
+
export type Equal<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
|
|
9
|
+
export type isTrue<T extends true> = T;
|
|
10
|
+
export type SliceFromStart<T extends unknown[], End extends number, Target extends unknown[] = []> = T['length'] | End extends 0 ? [] : Target['length'] extends End ? Target : T extends [infer A, ...infer R] ? SliceFromStart<R, End, [...Target, A]> : never;
|
|
11
|
+
export type Fn<T> = T extends (dep: infer D) => infer F ? {
|
|
12
|
+
arg: D;
|
|
13
|
+
return: F;
|
|
14
|
+
} : never;
|
|
15
|
+
export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
16
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
17
|
+
export type DistributivePick<T, K extends keyof T> = T extends unknown ? Pick<T, K> : never;
|
|
18
|
+
export type DistributiveJoin<T, U> = T extends unknown ? U extends unknown ? T & U : never : never;
|
|
19
|
+
export type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
|
|
20
|
+
export type Validate<T> = {
|
|
21
|
+
parse: (value: unknown) => T;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=typeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../src/typeUtils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnC,MA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ACI,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,CAAA;CACZ,GACD,KAAK,CAAA;AAGX,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACjC,CAAC,SAAS,OAAO,GACX,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GACd,KAAK,CACd,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GACxB,CAAC,GACD,KAAK,CAAA;AAEX,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;AAE1C,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,OAAO,GAChE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACV,KAAK,CAAA;AACX,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,OAAO,GAChD,CAAC,SAAS,OAAO,GACb,CAAC,GAAG,CAAC,GACL,KAAK,GACT,KAAK,CAAA;AACX,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,SAAS,OAAO,GAChE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACV,KAAK,CAAA;AAEX,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACtB,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAA;CAC/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../src/typeUtils.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rotorise",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Supercharge your DynamoDB with Rotorise!",
|
|
5
|
+
"main": "src/dist/Rotorise.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"AWS",
|
|
8
|
+
"Dynamodb",
|
|
9
|
+
"Typescript",
|
|
10
|
+
"brushless"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/josher8a/rotorise.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/josher8a/rotorise/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/josher8a/rotorise",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"test": "tsc --noEmit && jest \"src/(.+).spec.ts\""
|
|
23
|
+
},
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Joshua Hernandez",
|
|
26
|
+
"email": "josher8a@gmail.com"
|
|
27
|
+
},
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/jest": "^29.2.2",
|
|
31
|
+
"@types/node": "^18.11.9",
|
|
32
|
+
"jest": "^29.3.1",
|
|
33
|
+
"ts-jest": "^29.0.3",
|
|
34
|
+
"typescript": "^5.4.5"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"type-fest": "^4.18.3"
|
|
38
|
+
}
|
|
39
|
+
}
|