kirby-types 0.6.5 → 0.7.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/kirby-types?color=a1b858&label=)](https://www.npmjs.com/package/kirby-types)
4
4
 
5
- A collection of TypeScript types to work with [Kirby CMS](https://getkirby.com), mainly in the context of the Kirby Query Language.
5
+ A collection of TypeScript types to work with [Kirby CMS](https://getkirby.com), mainly in the context of the Kirby Query Language and [headless Kirby usage](https://github.com/johannschopplich/kirby-headless).
6
6
 
7
7
  ## Setup
8
8
 
@@ -36,9 +36,13 @@ invalidQuery = 'site("value"'; // Missing closing parenthesis
36
36
 
37
37
  By clicking on a type name, you will be redirected to the corresponding TypeScript definition file.
38
38
 
39
+ ### API
40
+
41
+ - [`KirbyApiResponse`](./src/api.d.ts) - Matches the response of a [Kirby API request](https://getkirby.com/docs/reference/api).
42
+
39
43
  ### Query
40
44
 
41
- - [`KirbyQueryModel`](./src/query.d.ts) - Matches any [supported KirbyQL model](https://github.com/getkirby/kql/blob/66abd20093e5656b0f7e6f51ee04f630ab38f2a3/src/Kql/Kql.php#L73).
45
+ - [`KirbyQueryModel`](./src/query.d.ts) - Matches any supported KirbyQL model.
42
46
  - [`KirbyQuery`](./src/query.d.ts) - Matches a KirbyQL [`query`](https://getkirby.com/docs/guide/blueprints/query-language).
43
47
 
44
48
  ### Blocks
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./src/api";
1
2
  export * from "./src/blocks";
2
3
  export * from "./src/kql";
3
4
  export * from "./src/layout";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirby-types",
3
3
  "type": "module",
4
- "version": "0.6.5",
5
- "packageManager": "pnpm@8.7.6",
4
+ "version": "0.7.0",
5
+ "packageManager": "pnpm@8.15.1",
6
6
  "description": "A collection of TypeScript types for the Kirby CMS",
7
7
  "author": "Johann Schopplich <pkg@johannschopplich.com>",
8
8
  "license": "MIT",
@@ -29,23 +29,23 @@
29
29
  },
30
30
  "types": "./index.d.ts",
31
31
  "files": [
32
- "src",
33
- "index.d.ts"
32
+ "index.d.ts",
33
+ "src"
34
34
  ],
35
35
  "scripts": {
36
- "lint": "eslint \"**/*.ts\" --ignore-path .gitignore",
37
- "lint:fix": "npm run lint -- --fix",
36
+ "lint": "eslint .",
37
+ "lint:fix": "eslint . --fix",
38
38
  "format": "prettier \"**/*.{css,html,json,md,mjs,ts,vue,yml}\" --write",
39
39
  "format:check": "prettier \"**/*.{css,html,json,md,mjs,ts,vue,yml}\" --check",
40
40
  "release": "bumpp --commit --push --tag",
41
41
  "test": "tsd -f \"test/**/*.test-d.ts\""
42
42
  },
43
43
  "devDependencies": {
44
- "@byjohann/eslint-config": "^0.2.2",
45
- "bumpp": "^9.2.0",
46
- "eslint": "^8.49.0",
47
- "prettier": "^3.0.3",
48
- "tsd": "^0.29.0",
49
- "typescript": "^5.2.2"
44
+ "@antfu/eslint-config": "^2.6.4",
45
+ "bumpp": "^9.3.0",
46
+ "eslint": "^8.56.0",
47
+ "prettier": "^3.2.5",
48
+ "tsd": "^0.30.4",
49
+ "typescript": "^5.3.3"
50
50
  }
51
51
  }
package/src/api.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface KirbyApiResponse<T = any> {
2
+ code: number;
3
+ status: string;
4
+ result?: T;
5
+ }
package/src/blocks.d.ts CHANGED
@@ -26,8 +26,8 @@ export interface KirbyBlock<
26
26
  content: U extends Record<string, unknown>
27
27
  ? U
28
28
  : T extends keyof KirbyDefaultBlocks
29
- ? KirbyDefaultBlocks[T]
30
- : Record<string, never>;
29
+ ? KirbyDefaultBlocks[T]
30
+ : Record<string, never>;
31
31
  id: string;
32
32
  isHidden: boolean;
33
33
  type: T;
package/src/kql.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { KirbyApiResponse } from "./api";
1
2
  import type { KirbyQuery } from "./query";
2
3
 
3
4
  export interface KirbyQuerySchema {
@@ -15,13 +16,11 @@ export interface KirbyQueryRequest extends KirbyQuerySchema {
15
16
  };
16
17
  }
17
18
 
18
- export interface KirbyQueryResponse<
19
+ export type KirbyQueryResponse<
19
20
  T = any,
20
21
  Pagination extends boolean = false,
21
- > {
22
- code: number;
23
- status: string;
24
- result?: Pagination extends true
22
+ > = KirbyApiResponse<
23
+ Pagination extends true
25
24
  ? {
26
25
  data: T;
27
26
  pagination: {
@@ -32,5 +31,5 @@ export interface KirbyQueryResponse<
32
31
  total: number;
33
32
  };
34
33
  }
35
- : T;
36
- }
34
+ : T
35
+ >;
package/src/query.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- // https://github.com/getkirby/kql/blob/4c8cdd88c076cdef5323efcd4f0fda38c0865eed/src/Kql/Kql.php#L73
2
1
  export type KirbyQueryModel<CustomModel extends string = never> =
3
2
  | "collection"
4
- | "file"
5
3
  | "kirby"
6
- | "page"
7
4
  | "site"
5
+ | "page"
8
6
  | "user"
7
+ | "file"
8
+ | "content"
9
+ | "item"
9
10
  | "arrayItem"
10
11
  | "structureItem"
11
12
  | "block"