@camox/api-contract 0.7.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.md +110 -0
- package/dist/index.d.ts +5906 -0
- package/dist/index.js +1 -0
- package/dist/query-keys.d.ts +33 -0
- package/dist/query-keys.js +23 -0
- package/package.json +25 -0
- package/src/index.ts +1 -0
- package/src/query-keys.ts +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// type-only module
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use TypeScript to enforce 'camox' as the first query key to ensure they're all namespaced.
|
|
3
|
+
* This is because the Tanstack Query client on the frontend may be shared with the user's routes,
|
|
4
|
+
* so we ensure there won't be any key collisions.
|
|
5
|
+
*/
|
|
6
|
+
export type QueryKey = [first: "camox", ...rest: Array<string | number>];
|
|
7
|
+
export declare const queryKeys: {
|
|
8
|
+
pages: {
|
|
9
|
+
list: ["camox", string, string];
|
|
10
|
+
getByPath: (path: string) => ["camox", string, string, string];
|
|
11
|
+
getByPathAll: ["camox", string, string];
|
|
12
|
+
getById: (id: number) => ["camox", string, string, number];
|
|
13
|
+
};
|
|
14
|
+
files: {
|
|
15
|
+
list: ["camox", string, string];
|
|
16
|
+
get: (id: number) => ["camox", string, string, number];
|
|
17
|
+
};
|
|
18
|
+
blocks: {
|
|
19
|
+
get: (id: number) => ["camox", string, string, number];
|
|
20
|
+
getUsageCounts: ["camox", string, string];
|
|
21
|
+
getPageMarkdown: (pageId: number) => ["camox", string, string, number];
|
|
22
|
+
};
|
|
23
|
+
repeatableItems: {
|
|
24
|
+
get: (id: number) => ["camox", string, string, number];
|
|
25
|
+
};
|
|
26
|
+
layouts: {
|
|
27
|
+
all: ["camox", string];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type InvalidationMessage = {
|
|
31
|
+
type: "invalidate";
|
|
32
|
+
targets: QueryKey[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const queryKeys = {
|
|
2
|
+
pages: {
|
|
3
|
+
list: ["camox", "pages", "list"],
|
|
4
|
+
getByPath: (path) => ["camox", "pages", "getByPath", path],
|
|
5
|
+
getByPathAll: ["camox", "pages", "getByPath"],
|
|
6
|
+
getById: (id) => ["camox", "pages", "getById", id],
|
|
7
|
+
},
|
|
8
|
+
files: {
|
|
9
|
+
list: ["camox", "files", "list"],
|
|
10
|
+
get: (id) => ["camox", "files", "get", id],
|
|
11
|
+
},
|
|
12
|
+
blocks: {
|
|
13
|
+
get: (id) => ["camox", "blocks", "get", id],
|
|
14
|
+
getUsageCounts: ["camox", "blocks", "getUsageCounts"],
|
|
15
|
+
getPageMarkdown: (pageId) => ["camox", "blocks", "getPageMarkdown", pageId],
|
|
16
|
+
},
|
|
17
|
+
repeatableItems: {
|
|
18
|
+
get: (id) => ["camox", "repeatableItems", "get", id],
|
|
19
|
+
},
|
|
20
|
+
layouts: {
|
|
21
|
+
all: ["camox", "layouts"],
|
|
22
|
+
},
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@camox/api-contract",
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"src",
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./query-keys": {
|
|
15
|
+
"types": "./dist/query-keys.d.ts",
|
|
16
|
+
"default": "./dist/query-keys.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"dts-bundle-generator": "^9.5.1"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "node build.mjs"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Router } from "../../../apps/api/src/router";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use TypeScript to enforce 'camox' as the first query key to ensure they're all namespaced.
|
|
3
|
+
* This is because the Tanstack Query client on the frontend may be shared with the user's routes,
|
|
4
|
+
* so we ensure there won't be any key collisions.
|
|
5
|
+
*/
|
|
6
|
+
export type QueryKey = [first: "camox", ...rest: Array<string | number>];
|
|
7
|
+
type QueryKeyGroup = Record<string, QueryKey | ((...args: any[]) => QueryKey)>;
|
|
8
|
+
|
|
9
|
+
export const queryKeys = {
|
|
10
|
+
pages: {
|
|
11
|
+
list: ["camox", "pages", "list"],
|
|
12
|
+
getByPath: (path: string) => ["camox", "pages", "getByPath", path],
|
|
13
|
+
getByPathAll: ["camox", "pages", "getByPath"],
|
|
14
|
+
getById: (id: number) => ["camox", "pages", "getById", id],
|
|
15
|
+
},
|
|
16
|
+
files: {
|
|
17
|
+
list: ["camox", "files", "list"],
|
|
18
|
+
get: (id: number) => ["camox", "files", "get", id],
|
|
19
|
+
},
|
|
20
|
+
blocks: {
|
|
21
|
+
get: (id: number) => ["camox", "blocks", "get", id],
|
|
22
|
+
getUsageCounts: ["camox", "blocks", "getUsageCounts"],
|
|
23
|
+
getPageMarkdown: (pageId: number) => ["camox", "blocks", "getPageMarkdown", pageId],
|
|
24
|
+
},
|
|
25
|
+
repeatableItems: {
|
|
26
|
+
get: (id: number) => ["camox", "repeatableItems", "get", id],
|
|
27
|
+
},
|
|
28
|
+
layouts: {
|
|
29
|
+
all: ["camox", "layouts"],
|
|
30
|
+
},
|
|
31
|
+
} satisfies Record<string, QueryKeyGroup>;
|
|
32
|
+
|
|
33
|
+
export type InvalidationMessage = {
|
|
34
|
+
type: "invalidate";
|
|
35
|
+
targets: QueryKey[];
|
|
36
|
+
};
|