@wix/cache 1.0.4 → 1.0.6
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/build/cjs/index.d.ts +2 -1
- package/build/cjs/index.js +2 -1
- package/build/cjs/index.js.map +1 -1
- package/build/es/index.d.ts +2 -1
- package/build/es/index.js +2 -1
- package/build/es/index.js.map +1 -1
- package/context/package.json +2 -1
- package/meta/package.json +2 -1
- package/package.json +12 -6
- package/type-bundles/context.bundle.d.ts +89 -0
- package/type-bundles/index.bundle.d.ts +89 -0
- package/type-bundles/meta.bundle.d.ts +51 -0
package/build/cjs/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as cache from '@wix/cache_cache';
|
|
2
|
+
export { cache };
|
package/build/cjs/index.js
CHANGED
|
@@ -24,5 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.cache = void 0;
|
|
27
|
-
|
|
27
|
+
const cache = __importStar(require("@wix/cache_cache"));
|
|
28
|
+
exports.cache = cache;
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAEjC,sBAAK"}
|
package/build/es/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as cache from '@wix/cache_cache';
|
|
2
|
+
export { cache };
|
package/build/es/index.js
CHANGED
package/build/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/context/package.json
CHANGED
package/meta/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/cache",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -9,21 +9,27 @@
|
|
|
9
9
|
"module": "build/es/index.js",
|
|
10
10
|
"main": "build/cjs/index.js",
|
|
11
11
|
"typings": "./build/cjs/index.d.ts",
|
|
12
|
+
"typesBundle": "./type-bundles/index.bundle.d.ts",
|
|
12
13
|
"files": [
|
|
13
14
|
"build",
|
|
14
15
|
"frontend/package.json",
|
|
15
16
|
"meta",
|
|
16
|
-
"context"
|
|
17
|
+
"context",
|
|
18
|
+
"type-bundles"
|
|
17
19
|
],
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@wix/cache_cache": "1.0.
|
|
21
|
+
"@wix/cache_cache": "1.0.6"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
|
-
"
|
|
24
|
+
"glob": "^10.4.1",
|
|
25
|
+
"rollup": "^4.18.0",
|
|
26
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
23
27
|
"typescript": "^5.3.2"
|
|
24
28
|
},
|
|
25
29
|
"scripts": {
|
|
26
|
-
"build": "tsc -b tsconfig.json tsconfig.esm.json",
|
|
30
|
+
"build": "tsc -b tsconfig.json tsconfig.esm.json && npm run build:dts-bundles && npm run build:validate-dts",
|
|
31
|
+
"build:dts-bundles": "test -f config/rollup-config.js && NODE_OPTIONS=--max-old-space-size=8192 rollup --config config/rollup-config.js || echo 'Warning: config/rollup-config.js not found!'",
|
|
32
|
+
"build:validate-dts": "tsc type-bundles/*.d.ts --noEmit",
|
|
27
33
|
"test": ":"
|
|
28
34
|
},
|
|
29
35
|
"wix": {
|
|
@@ -37,5 +43,5 @@
|
|
|
37
43
|
"fqdn": ""
|
|
38
44
|
}
|
|
39
45
|
},
|
|
40
|
-
"falconPackageHash": "
|
|
46
|
+
"falconPackageHash": "f03674336942a82ba8490548a0256d05b3c7ac3ec5a44ab3f44aa237"
|
|
41
47
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
2
|
+
interface HttpClient {
|
|
3
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
4
|
+
fetchWithAuth: typeof fetch;
|
|
5
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
6
|
+
}
|
|
7
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
8
|
+
type HttpResponse<T = any> = {
|
|
9
|
+
data: T;
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
headers: any;
|
|
13
|
+
request?: any;
|
|
14
|
+
};
|
|
15
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
16
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
17
|
+
url: string;
|
|
18
|
+
data?: Data;
|
|
19
|
+
params?: URLSearchParams;
|
|
20
|
+
} & APIMetadata;
|
|
21
|
+
type APIMetadata = {
|
|
22
|
+
methodFqn?: string;
|
|
23
|
+
entityFqdn?: string;
|
|
24
|
+
packageName?: string;
|
|
25
|
+
};
|
|
26
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
27
|
+
|
|
28
|
+
declare global {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
30
|
+
interface SymbolConstructor {
|
|
31
|
+
readonly observable: symbol;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface InvalidateCacheRequest {
|
|
36
|
+
/** An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. */
|
|
37
|
+
invalidationMethods?: InvalidationMethods[];
|
|
38
|
+
}
|
|
39
|
+
interface InvalidationMethods extends InvalidationMethodsInvalidateByOneOf {
|
|
40
|
+
/** Identifiers of the caches to invalidate. */
|
|
41
|
+
tag?: string;
|
|
42
|
+
}
|
|
43
|
+
/** @oneof */
|
|
44
|
+
interface InvalidationMethodsInvalidateByOneOf {
|
|
45
|
+
/** Identifiers of the caches to invalidate. */
|
|
46
|
+
tag?: string;
|
|
47
|
+
}
|
|
48
|
+
interface InvalidateCacheResponse {
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare function invalidateCache$1(httpClient: HttpClient): InvalidateCacheSignature;
|
|
52
|
+
interface InvalidateCacheSignature {
|
|
53
|
+
/**
|
|
54
|
+
* Clears caches using specified tags.
|
|
55
|
+
*
|
|
56
|
+
* This function invalidates or clears previously cached return values based on specified tags. The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values for routers using the [`ok()` function](https://dev.wix.com/docs/velo/api-reference/wix-router/ok). For example, an array such as `[{ tag: "contacts" }, { tag: "labels" }]` will clear any cached return values tagged with "contacts" or "labels." Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* <blockquote class="important">
|
|
60
|
+
*
|
|
61
|
+
* __Important:__
|
|
62
|
+
* - If you don't specify any tags in the `invalidationsMethod` parameter, no caches are invalidated.
|
|
63
|
+
* - If you don't use the `invalidateCache()` function, your caches are only invalidated when the Time to Live (TTL) expires or when you republish your site with a code change.
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* - This function invalidates router caches. To invalidate the Server Side Rendering (SSR) cache for your site, use the `invalidateCache()` function from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache) module.
|
|
67
|
+
*
|
|
68
|
+
* </blockquote>
|
|
69
|
+
* @param - An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated.
|
|
70
|
+
*/
|
|
71
|
+
(invalidationMethods: InvalidationMethods[]): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare function createRESTModule<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
|
|
75
|
+
|
|
76
|
+
type _publicInvalidateCacheType = typeof invalidateCache$1;
|
|
77
|
+
declare const invalidateCache: ReturnType<typeof createRESTModule<_publicInvalidateCacheType>>;
|
|
78
|
+
|
|
79
|
+
type context_InvalidateCacheRequest = InvalidateCacheRequest;
|
|
80
|
+
type context_InvalidateCacheResponse = InvalidateCacheResponse;
|
|
81
|
+
type context_InvalidationMethods = InvalidationMethods;
|
|
82
|
+
type context_InvalidationMethodsInvalidateByOneOf = InvalidationMethodsInvalidateByOneOf;
|
|
83
|
+
type context__publicInvalidateCacheType = _publicInvalidateCacheType;
|
|
84
|
+
declare const context_invalidateCache: typeof invalidateCache;
|
|
85
|
+
declare namespace context {
|
|
86
|
+
export { type context_InvalidateCacheRequest as InvalidateCacheRequest, type context_InvalidateCacheResponse as InvalidateCacheResponse, type context_InvalidationMethods as InvalidationMethods, type context_InvalidationMethodsInvalidateByOneOf as InvalidationMethodsInvalidateByOneOf, type context__publicInvalidateCacheType as _publicInvalidateCacheType, context_invalidateCache as invalidateCache };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { context as cache };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
|
|
2
|
+
interface HttpClient {
|
|
3
|
+
request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
|
|
4
|
+
fetchWithAuth: typeof fetch;
|
|
5
|
+
wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
|
|
6
|
+
}
|
|
7
|
+
type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
|
|
8
|
+
type HttpResponse<T = any> = {
|
|
9
|
+
data: T;
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
headers: any;
|
|
13
|
+
request?: any;
|
|
14
|
+
};
|
|
15
|
+
type RequestOptions<_TResponse = any, Data = any> = {
|
|
16
|
+
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
17
|
+
url: string;
|
|
18
|
+
data?: Data;
|
|
19
|
+
params?: URLSearchParams;
|
|
20
|
+
} & APIMetadata;
|
|
21
|
+
type APIMetadata = {
|
|
22
|
+
methodFqn?: string;
|
|
23
|
+
entityFqdn?: string;
|
|
24
|
+
packageName?: string;
|
|
25
|
+
};
|
|
26
|
+
type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
|
|
27
|
+
|
|
28
|
+
declare global {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
30
|
+
interface SymbolConstructor {
|
|
31
|
+
readonly observable: symbol;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface InvalidateCacheRequest {
|
|
36
|
+
/** An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. */
|
|
37
|
+
invalidationMethods?: InvalidationMethods[];
|
|
38
|
+
}
|
|
39
|
+
interface InvalidationMethods extends InvalidationMethodsInvalidateByOneOf {
|
|
40
|
+
/** Identifiers of the caches to invalidate. */
|
|
41
|
+
tag?: string;
|
|
42
|
+
}
|
|
43
|
+
/** @oneof */
|
|
44
|
+
interface InvalidationMethodsInvalidateByOneOf {
|
|
45
|
+
/** Identifiers of the caches to invalidate. */
|
|
46
|
+
tag?: string;
|
|
47
|
+
}
|
|
48
|
+
interface InvalidateCacheResponse {
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare function invalidateCache$1(httpClient: HttpClient): InvalidateCacheSignature;
|
|
52
|
+
interface InvalidateCacheSignature {
|
|
53
|
+
/**
|
|
54
|
+
* Clears caches using specified tags.
|
|
55
|
+
*
|
|
56
|
+
* This function invalidates or clears previously cached return values based on specified tags. The `invalidationMethods` parameter accepts an array of objects, each containing a `tag` field. These tags are defined when caching return values for routers using the [`ok()` function](https://dev.wix.com/docs/velo/api-reference/wix-router/ok). For example, an array such as `[{ tag: "contacts" }, { tag: "labels" }]` will clear any cached return values tagged with "contacts" or "labels." Any cache containing at least one tag specified in the `invalidationMethods` parameter will be cleared.
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* <blockquote class="important">
|
|
60
|
+
*
|
|
61
|
+
* __Important:__
|
|
62
|
+
* - If you don't specify any tags in the `invalidationsMethod` parameter, no caches are invalidated.
|
|
63
|
+
* - If you don't use the `invalidateCache()` function, your caches are only invalidated when the Time to Live (TTL) expires or when you republish your site with a code change.
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* - This function invalidates router caches. To invalidate the Server Side Rendering (SSR) cache for your site, use the `invalidateCache()` function from the [`wix-site-backend`](https://dev.wix.com/docs/velo/api-reference/wix-site-backend/invalidate-cache) module.
|
|
67
|
+
*
|
|
68
|
+
* </blockquote>
|
|
69
|
+
* @param - An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated.
|
|
70
|
+
*/
|
|
71
|
+
(invalidationMethods: InvalidationMethods[]): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare function createRESTModule<T extends RESTFunctionDescriptor>(descriptor: T, elevated?: boolean): BuildRESTFunction<T> & T;
|
|
75
|
+
|
|
76
|
+
type _publicInvalidateCacheType = typeof invalidateCache$1;
|
|
77
|
+
declare const invalidateCache: ReturnType<typeof createRESTModule<_publicInvalidateCacheType>>;
|
|
78
|
+
|
|
79
|
+
type index_d_InvalidateCacheRequest = InvalidateCacheRequest;
|
|
80
|
+
type index_d_InvalidateCacheResponse = InvalidateCacheResponse;
|
|
81
|
+
type index_d_InvalidationMethods = InvalidationMethods;
|
|
82
|
+
type index_d_InvalidationMethodsInvalidateByOneOf = InvalidationMethodsInvalidateByOneOf;
|
|
83
|
+
type index_d__publicInvalidateCacheType = _publicInvalidateCacheType;
|
|
84
|
+
declare const index_d_invalidateCache: typeof invalidateCache;
|
|
85
|
+
declare namespace index_d {
|
|
86
|
+
export { type index_d_InvalidateCacheRequest as InvalidateCacheRequest, type index_d_InvalidateCacheResponse as InvalidateCacheResponse, type index_d_InvalidationMethods as InvalidationMethods, type index_d_InvalidationMethodsInvalidateByOneOf as InvalidationMethodsInvalidateByOneOf, type index_d__publicInvalidateCacheType as _publicInvalidateCacheType, index_d_invalidateCache as invalidateCache };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { index_d as cache };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface InvalidateCacheRequest$1 {
|
|
2
|
+
/** An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. */
|
|
3
|
+
invalidationMethods?: InvalidationMethods$1[];
|
|
4
|
+
}
|
|
5
|
+
interface InvalidationMethods$1 extends InvalidationMethodsInvalidateByOneOf$1 {
|
|
6
|
+
/** Identifiers of the caches to invalidate. */
|
|
7
|
+
tag?: string;
|
|
8
|
+
}
|
|
9
|
+
/** @oneof */
|
|
10
|
+
interface InvalidationMethodsInvalidateByOneOf$1 {
|
|
11
|
+
/** Identifiers of the caches to invalidate. */
|
|
12
|
+
tag?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InvalidateCacheResponse$1 {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface InvalidateCacheRequest {
|
|
18
|
+
/** An array of objects containing a `tag` field used to identify the cache to invalidate. All cached return values with any listed tags are invalidated. If no tags are specified, nothing is invalidated. */
|
|
19
|
+
invalidationMethods?: InvalidationMethods[];
|
|
20
|
+
}
|
|
21
|
+
interface InvalidationMethods extends InvalidationMethodsInvalidateByOneOf {
|
|
22
|
+
/** Identifiers of the caches to invalidate. */
|
|
23
|
+
tag?: string;
|
|
24
|
+
}
|
|
25
|
+
/** @oneof */
|
|
26
|
+
interface InvalidationMethodsInvalidateByOneOf {
|
|
27
|
+
/** Identifiers of the caches to invalidate. */
|
|
28
|
+
tag?: string;
|
|
29
|
+
}
|
|
30
|
+
interface InvalidateCacheResponse {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q = unknown, R = unknown> = {
|
|
34
|
+
getUrl: (context: any) => string;
|
|
35
|
+
httpMethod: K;
|
|
36
|
+
path: string;
|
|
37
|
+
pathParams: M;
|
|
38
|
+
__requestType: T;
|
|
39
|
+
__originalRequestType: S;
|
|
40
|
+
__responseType: Q;
|
|
41
|
+
__originalResponseType: R;
|
|
42
|
+
};
|
|
43
|
+
declare function invalidateCache(): __PublicMethodMetaInfo<'POST', {}, InvalidateCacheRequest, InvalidateCacheRequest$1, InvalidateCacheResponse, InvalidateCacheResponse$1>;
|
|
44
|
+
|
|
45
|
+
type meta___PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q = unknown, R = unknown> = __PublicMethodMetaInfo<K, M, T, S, Q, R>;
|
|
46
|
+
declare const meta_invalidateCache: typeof invalidateCache;
|
|
47
|
+
declare namespace meta {
|
|
48
|
+
export { type meta___PublicMethodMetaInfo as __PublicMethodMetaInfo, meta_invalidateCache as invalidateCache };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { meta as cache };
|