@occultist/occultist 0.0.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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/accept.d.ts +41 -0
- package/dist/accept.js +110 -0
- package/dist/accept.test.d.ts +1 -0
- package/dist/accept.test.js +44 -0
- package/dist/action.test.d.ts +1 -0
- package/dist/action.test.js +1 -0
- package/dist/actions/actionSets.d.ts +23 -0
- package/dist/actions/actionSets.js +49 -0
- package/dist/actions/actions.d.ts +163 -0
- package/dist/actions/actions.js +436 -0
- package/dist/actions/context.d.ts +78 -0
- package/dist/actions/context.js +112 -0
- package/dist/actions/meta.d.ts +49 -0
- package/dist/actions/meta.js +177 -0
- package/dist/actions/path.d.ts +21 -0
- package/dist/actions/path.js +83 -0
- package/dist/actions/path.test.d.ts +1 -0
- package/dist/actions/path.test.js +9 -0
- package/dist/actions/spec.d.ts +214 -0
- package/dist/actions/spec.js +1 -0
- package/dist/actions/types.d.ts +112 -0
- package/dist/actions/types.js +2 -0
- package/dist/actions/writer.d.ts +27 -0
- package/dist/actions/writer.js +140 -0
- package/dist/actions/writer.test.d.ts +1 -0
- package/dist/actions/writer.test.js +42 -0
- package/dist/auth/types.d.ts +14 -0
- package/dist/auth/types.js +1 -0
- package/dist/cache/cache.d.ts +30 -0
- package/dist/cache/cache.js +220 -0
- package/dist/cache/etag.d.ts +17 -0
- package/dist/cache/etag.js +83 -0
- package/dist/cache/etag.test.d.ts +1 -0
- package/dist/cache/etag.test.js +91 -0
- package/dist/cache/memory.d.ts +12 -0
- package/dist/cache/memory.js +36 -0
- package/dist/cache/types.d.ts +175 -0
- package/dist/cache/types.js +4 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +54 -0
- package/dist/jsonld.d.ts +43 -0
- package/dist/jsonld.js +1 -0
- package/dist/makeTypeDefs.d.ts +27 -0
- package/dist/makeTypeDefs.js +70 -0
- package/dist/merge.d.ts +61 -0
- package/dist/merge.js +1 -0
- package/dist/mod.d.ts +14 -0
- package/dist/mod.js +14 -0
- package/dist/processAction.d.ts +15 -0
- package/dist/processAction.js +512 -0
- package/dist/registry.d.ts +88 -0
- package/dist/registry.js +314 -0
- package/dist/registry.test.d.ts +1 -0
- package/dist/registry.test.js +133 -0
- package/dist/request.d.ts +29 -0
- package/dist/request.js +118 -0
- package/dist/scopes.d.ts +35 -0
- package/dist/scopes.js +121 -0
- package/dist/scopes.test.d.ts +1 -0
- package/dist/scopes.test.js +55 -0
- package/dist/transformers/fileTransformer.d.ts +1 -0
- package/dist/transformers/fileTransformer.js +8 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +1 -0
- package/dist/utils/alwaysArray.d.ts +1 -0
- package/dist/utils/alwaysArray.js +9 -0
- package/dist/utils/contextBuilder.d.ts +9 -0
- package/dist/utils/contextBuilder.js +82 -0
- package/dist/utils/getActionContext.d.ts +7 -0
- package/dist/utils/getActionContext.js +48 -0
- package/dist/utils/getInternalName.d.ts +6 -0
- package/dist/utils/getInternalName.js +7 -0
- package/dist/utils/getParamLocation.d.ts +2 -0
- package/dist/utils/getParamLocation.js +6 -0
- package/dist/utils/getPropertyValueSpecifications.d.ts +2 -0
- package/dist/utils/getPropertyValueSpecifications.js +49 -0
- package/dist/utils/getRequestBodyValues.d.ts +11 -0
- package/dist/utils/getRequestBodyValues.js +122 -0
- package/dist/utils/getRequestIRIValues.d.ts +14 -0
- package/dist/utils/getRequestIRIValues.js +133 -0
- package/dist/utils/isBodyInit.d.ts +1 -0
- package/dist/utils/isBodyInit.js +21 -0
- package/dist/utils/isNil.d.ts +1 -0
- package/dist/utils/isNil.js +4 -0
- package/dist/utils/isObject.d.ts +6 -0
- package/dist/utils/isObject.js +6 -0
- package/dist/utils/isPopulatedObject.d.ts +5 -0
- package/dist/utils/isPopulatedObject.js +8 -0
- package/dist/utils/isPopulatedString.d.ts +1 -0
- package/dist/utils/isPopulatedString.js +4 -0
- package/dist/utils/joinPaths.d.ts +1 -0
- package/dist/utils/joinPaths.js +31 -0
- package/dist/utils/makeAppendProblemDetails.d.ts +14 -0
- package/dist/utils/makeAppendProblemDetails.js +26 -0
- package/dist/utils/makeURLPattern.d.ts +5 -0
- package/dist/utils/makeURLPattern.js +12 -0
- package/dist/utils/normalizeURL.d.ts +4 -0
- package/dist/utils/normalizeURL.js +11 -0
- package/dist/utils/parseSearchParams.d.ts +3 -0
- package/dist/utils/parseSearchParams.js +24 -0
- package/dist/utils/preferredMediaTypes.d.ts +42 -0
- package/dist/utils/preferredMediaTypes.js +149 -0
- package/dist/utils/urlToIRI.d.ts +1 -0
- package/dist/utils/urlToIRI.js +8 -0
- package/dist/utils/validateSpecValue.d.ts +1 -0
- package/dist/utils/validateSpecValue.js +1 -0
- package/dist/validators.d.ts +16 -0
- package/dist/validators.js +134 -0
- package/lib/accept.test.ts +55 -0
- package/lib/accept.ts +147 -0
- package/lib/action.test.ts +2 -0
- package/lib/actions/actionSets.ts +88 -0
- package/lib/actions/actions.ts +795 -0
- package/lib/actions/context.ts +170 -0
- package/lib/actions/meta.ts +251 -0
- package/lib/actions/path.test.ts +15 -0
- package/lib/actions/path.ts +99 -0
- package/lib/actions/spec.ts +545 -0
- package/lib/actions/types.ts +146 -0
- package/lib/actions/writer.test.ts +57 -0
- package/lib/actions/writer.ts +176 -0
- package/lib/auth/types.ts +22 -0
- package/lib/cache/cache.ts +291 -0
- package/lib/cache/etag.test.ts +122 -0
- package/lib/cache/etag.ts +106 -0
- package/lib/cache/memory.ts +52 -0
- package/lib/cache/types.ts +240 -0
- package/lib/errors.ts +66 -0
- package/lib/jsonld.ts +67 -0
- package/lib/makeTypeDefs.ts +138 -0
- package/lib/merge.ts +86 -0
- package/lib/mod.ts +14 -0
- package/lib/processAction.ts +690 -0
- package/lib/registry.test.ts +174 -0
- package/lib/registry.ts +455 -0
- package/lib/request.ts +153 -0
- package/lib/scopes.test.ts +70 -0
- package/lib/scopes.ts +178 -0
- package/lib/transformers/fileTransformer.ts +10 -0
- package/lib/types.ts +13 -0
- package/lib/utils/alwaysArray.ts +10 -0
- package/lib/utils/contextBuilder.ts +111 -0
- package/lib/utils/getActionContext.ts +76 -0
- package/lib/utils/getInternalName.ts +15 -0
- package/lib/utils/getParamLocation.ts +14 -0
- package/lib/utils/getPropertyValueSpecifications.ts +76 -0
- package/lib/utils/getRequestBodyValues.ts +155 -0
- package/lib/utils/getRequestIRIValues.ts +201 -0
- package/lib/utils/isBodyInit.ts +22 -0
- package/lib/utils/isNil.ts +4 -0
- package/lib/utils/isObject.ts +8 -0
- package/lib/utils/isPopulatedObject.ts +9 -0
- package/lib/utils/isPopulatedString.ts +4 -0
- package/lib/utils/joinPaths.ts +36 -0
- package/lib/utils/makeAppendProblemDetails.ts +57 -0
- package/lib/utils/makeURLPattern.ts +18 -0
- package/lib/utils/normalizeURL.ts +15 -0
- package/lib/utils/parseSearchParams.ts +36 -0
- package/lib/utils/preferredMediaTypes.ts +220 -0
- package/lib/utils/urlToIRI.ts +11 -0
- package/lib/utils/validateSpecValue.ts +0 -0
- package/lib/validators.ts +186 -0
- package/package.json +41 -0
package/lib/merge.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
export type ShallowMerge<T1 extends object, T2 extends object> =
|
|
3
|
+
& { [K in keyof T1 & keyof T2]: T1[K] | T2[K] }
|
|
4
|
+
& ({ [K in Exclude<keyof T1, keyof T2>]: T1[K] })
|
|
5
|
+
& ({ [K in Exclude<keyof T2, keyof T1>]: T2[K] });
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// it merge 2 static types and try to avoid of unnecessary options (`'`)
|
|
9
|
+
export type DeepMergeTwoTypes<T, U> =
|
|
10
|
+
// ----- 2 added lines ------
|
|
11
|
+
[T, U] extends [any[], any[]]
|
|
12
|
+
? Zip_DeepMergeTwoTypes<T, U>
|
|
13
|
+
// check if generic types are objects
|
|
14
|
+
: [T, U] extends [{ [key: string]: unknown }, { [key: string]: unknown }]
|
|
15
|
+
? MergeTwoObjects<T, U>
|
|
16
|
+
: T | U;
|
|
17
|
+
|
|
18
|
+
export type DeepMerge<T1, T2> = (
|
|
19
|
+
T1 extends object ? (
|
|
20
|
+
T2 extends object ? (
|
|
21
|
+
MergeToOne<(
|
|
22
|
+
{ [K in (keyof T2 & keyof T1 & RequiredKeys<T1 | T2>)]: DeepMerge<T1[K], T2[K]> }
|
|
23
|
+
& { [K in (keyof T2 & keyof T1 & OptionalKeys<T1 | T2>)]?: DeepMerge<T1[K], T2[K]> }
|
|
24
|
+
|
|
25
|
+
& { [K in Exclude<RequiredKeys<T1>, keyof T2>]: T1[K] }
|
|
26
|
+
& { [K in Exclude<OptionalKeys<T1>, keyof T2>]?: T1[K] }
|
|
27
|
+
|
|
28
|
+
& { [K in Exclude<RequiredKeys<T2>, keyof T1>]: T2[K] }
|
|
29
|
+
& { [K in Exclude<OptionalKeys<T2>, keyof T1>]?: T2[K] }
|
|
30
|
+
)>
|
|
31
|
+
) : (
|
|
32
|
+
T1 extends object ? T2 : T1 | T2
|
|
33
|
+
)
|
|
34
|
+
) : (
|
|
35
|
+
T2 extends object ? T1 : T1 | T2
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
type Head<T> = T extends [infer I, ...infer _Rest] ? I : never
|
|
40
|
+
type Tail<T> = T extends [infer _I, ...infer Rest] ? Rest : never
|
|
41
|
+
|
|
42
|
+
type Zip_DeepMergeTwoTypes<T, U> = T extends []
|
|
43
|
+
? U
|
|
44
|
+
: U extends []
|
|
45
|
+
? T
|
|
46
|
+
: [
|
|
47
|
+
DeepMergeTwoTypes<Head<T>, Head<U>>,
|
|
48
|
+
...Zip_DeepMergeTwoTypes<Tail<T>, Tail<U>>
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Take two objects T and U and create the new one with uniq keys for T a U objectI
|
|
54
|
+
* helper generic for `DeepMergeTwoTypes`
|
|
55
|
+
*/
|
|
56
|
+
type GetObjDifferentKeys<
|
|
57
|
+
T,
|
|
58
|
+
U,
|
|
59
|
+
T0 = Omit<T, keyof U> & Omit<U, keyof T>,
|
|
60
|
+
T1 = { [K in keyof T0]: T0[K] }
|
|
61
|
+
> = T1
|
|
62
|
+
/**
|
|
63
|
+
* Take two objects T and U and create the new one with the same objects keys
|
|
64
|
+
* helper generic for `DeepMergeTwoTypes`
|
|
65
|
+
*/
|
|
66
|
+
type GetObjSameKeys<T, U> = Omit<T | U, keyof GetObjDifferentKeys<T, U>>
|
|
67
|
+
|
|
68
|
+
type MergeTwoObjects<
|
|
69
|
+
T,
|
|
70
|
+
U,
|
|
71
|
+
// non shared keys are optional
|
|
72
|
+
T0 = Partial<GetObjDifferentKeys<T, U>>
|
|
73
|
+
// shared keys are recursively resolved by `DeepMergeTwoTypes<...>`
|
|
74
|
+
& { [K in keyof GetObjSameKeys<T, U>]: DeepMergeTwoTypes<T[K], U[K]> },
|
|
75
|
+
T1 = { [K in keyof T0]: T0[K] }
|
|
76
|
+
> = T1
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
type MergeToOne<T> = (
|
|
80
|
+
T extends object ? { [K in keyof T]: (
|
|
81
|
+
K extends RequiredKeys<T> ? Exclude<T[K], undefined> : T[K]
|
|
82
|
+
) } : never
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
86
|
+
type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T];
|
package/lib/mod.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './cache/types.js';
|
|
2
|
+
export * from './cache/cache.js';
|
|
3
|
+
export * from './cache/memory.js';
|
|
4
|
+
export * from './actions/types.js';
|
|
5
|
+
export * from './actions/meta.js';
|
|
6
|
+
export * from './actions/spec.js';
|
|
7
|
+
export * from './actions/context.js';
|
|
8
|
+
export * from './actions/path.js';
|
|
9
|
+
export * from './actions/actions.js';
|
|
10
|
+
export * from './actions/actionSets.js';
|
|
11
|
+
export * from './registry.js';
|
|
12
|
+
export * from './makeTypeDefs.js';
|
|
13
|
+
export * from './utils/joinPaths.js';
|
|
14
|
+
export * from './utils/contextBuilder.js';
|