@hyper-fetch/hono 1.0.0 → 9.8.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.
@@ -0,0 +1,112 @@
1
+ import { serve } from "@hono/node-server";
2
+ import type { ServerType } from "@hono/node-server";
3
+ import { createClient, createSdk } from "@hyper-fetch/core";
4
+ import type { AddressInfo } from "node:net";
5
+
6
+ import type { HonoAppToHyperFetch } from "../../../src";
7
+ import { app } from "../../utils/app";
8
+
9
+ type Schema = HonoAppToHyperFetch<typeof app>;
10
+
11
+ const startServer = () =>
12
+ new Promise<ServerType>((resolve) => {
13
+ const server = serve({ fetch: app.fetch, port: 0 }, () => resolve(server));
14
+ });
15
+
16
+ const stopServer = (server: ServerType) =>
17
+ new Promise<void>((resolve, reject) => {
18
+ server.close((error) => (error ? reject(error) : resolve()));
19
+ });
20
+
21
+ describe("HonoAppToHyperFetch [ Requests against a Hono server ]", () => {
22
+ let server: ServerType;
23
+ let url: string;
24
+
25
+ const createAppSdk = () => {
26
+ const client = createClient({ url });
27
+ return createSdk<typeof client, Schema>(client);
28
+ };
29
+
30
+ beforeAll(async () => {
31
+ server = await startServer();
32
+ url = `http://localhost:${(server.address() as AddressInfo).port}`;
33
+ });
34
+
35
+ afterAll(async () => {
36
+ await stopServer(server);
37
+ });
38
+
39
+ it("should send a GET to a mounted route", async () => {
40
+ const sdk = createAppSdk();
41
+
42
+ const { data, error, status } = await sdk.users.$get.send();
43
+
44
+ expect(status).toBe(200);
45
+ expect(error).toBeNull();
46
+ expect(data).toStrictEqual([{ id: "1", name: "Ann" }]);
47
+ });
48
+
49
+ it("should send to the root route", async () => {
50
+ const sdk = createAppSdk();
51
+
52
+ const { data } = await sdk.$get.send();
53
+
54
+ expect(data).toStrictEqual({ ok: true });
55
+ });
56
+
57
+ it("should fill :param segments from setParams", async () => {
58
+ const sdk = createAppSdk();
59
+
60
+ const { data } = await sdk.users.$userId.$get.setParams({ userId: "42" }).send();
61
+
62
+ expect(data).toStrictEqual({ id: "42", name: "Ann" });
63
+ });
64
+
65
+ it("should send the payload as the JSON body the validator reads", async () => {
66
+ const sdk = createAppSdk();
67
+
68
+ const { data, status } = await sdk.users.$post.setPayload({ name: "Bob" }).send();
69
+
70
+ expect(status).toBe(201);
71
+ expect(data).toStrictEqual({ id: "2", name: "Bob" });
72
+ });
73
+
74
+ it("should send query params the validator reads", async () => {
75
+ const sdk = createAppSdk();
76
+
77
+ const { data } = await sdk.users.$userId.posts.$get.setParams({ userId: "7" }).setQueryParams({ page: "3" }).send();
78
+
79
+ expect(data).toStrictEqual({ userId: "7", page: "3" });
80
+ });
81
+
82
+ it("should resolve camelCase accessors to the kebab-case Hono path", async () => {
83
+ const sdk = createAppSdk();
84
+ const request = sdk.auth.googleLogin.$get;
85
+
86
+ const { data } = await request.send();
87
+
88
+ expect(request.endpoint).toBe("/auth/google-login");
89
+ expect(data).toStrictEqual({ authUrl: "https://accounts.example.com" });
90
+ });
91
+
92
+ it("should send the HTTP method named by the key", async () => {
93
+ const sdk = createAppSdk();
94
+ const request = sdk.auth.session.$delete;
95
+
96
+ const { data } = await request.send();
97
+
98
+ expect(request.method).toBe("DELETE");
99
+ expect(data).toStrictEqual({ loggedOut: true });
100
+ });
101
+
102
+ it("should resolve an error status through the response", async () => {
103
+ const sdk = createAppSdk();
104
+
105
+ const { data, error, status, success } = await sdk.users.$userId.$get.setParams({ userId: "missing" }).send();
106
+
107
+ expect(success).toBe(false);
108
+ expect(status).toBe(404);
109
+ expect(data).toBeNull();
110
+ expect(error).toStrictEqual({ message: "User not found" });
111
+ });
112
+ });
@@ -0,0 +1,163 @@
1
+ import { createClient, createSdk } from "@hyper-fetch/core";
2
+ import type {
3
+ Client,
4
+ ClientInstance,
5
+ ExtractClientType,
6
+ ExtractEndpointType,
7
+ ExtractGlobalErrorType,
8
+ ExtractLocalErrorType,
9
+ ExtractPayloadType,
10
+ ExtractQueryParamsType,
11
+ ExtractResponseType,
12
+ HttpAdapterType,
13
+ } from "@hyper-fetch/core";
14
+ import { Hono } from "hono";
15
+ import { expectTypeOf } from "vitest";
16
+
17
+ import type { HonoAppToHyperFetch } from "../../../src";
18
+ import type { User, apiApp, app } from "../../utils/app";
19
+
20
+ type Schema = HonoAppToHyperFetch<typeof app>;
21
+
22
+ describe("HonoAppToHyperFetch [ Schema shape ]", () => {
23
+ it("should nest mounted routes under their path segments", () => {
24
+ expectTypeOf<keyof Schema>().toEqualTypeOf<"$get" | "users" | "auth">();
25
+ expectTypeOf<keyof Schema["users"]>().toEqualTypeOf<"$get" | "$post" | "$userId">();
26
+ expectTypeOf<keyof Schema["users"]["$userId"]>().toEqualTypeOf<"$get" | "posts">();
27
+ expectTypeOf<keyof Schema["auth"]>().toEqualTypeOf<"googleLogin" | "session">();
28
+ expect(true).toBe(true);
29
+ });
30
+
31
+ it("should turn :param segments into $param keys and keep the Hono path as the endpoint", () => {
32
+ expectTypeOf<ExtractEndpointType<Schema["users"]["$userId"]["$get"]>>().toEqualTypeOf<"/users/:userId">();
33
+ expectTypeOf<
34
+ ExtractEndpointType<Schema["users"]["$userId"]["posts"]["$get"]>
35
+ >().toEqualTypeOf<"/users/:userId/posts">();
36
+ expect(true).toBe(true);
37
+ });
38
+
39
+ it("should camelCase kebab-case segments and keep the kebab-case endpoint", () => {
40
+ expectTypeOf<ExtractEndpointType<Schema["auth"]["googleLogin"]["$get"]>>().toEqualTypeOf<"/auth/google-login">();
41
+ expect(true).toBe(true);
42
+ });
43
+
44
+ it("should put a route registered on / at the top level", () => {
45
+ expectTypeOf<ExtractEndpointType<Schema["$get"]>>().toEqualTypeOf<"/">();
46
+ expectTypeOf<ExtractResponseType<Schema["$get"]>>().toEqualTypeOf<{ ok: true }>();
47
+ expect(true).toBe(true);
48
+ });
49
+
50
+ it("should prefix endpoints with the app basePath", () => {
51
+ type ApiSchema = HonoAppToHyperFetch<typeof apiApp>;
52
+
53
+ expectTypeOf<keyof ApiSchema>().toEqualTypeOf<"api">();
54
+ expectTypeOf<ExtractEndpointType<ApiSchema["api"]["users"]["$get"]>>().toEqualTypeOf<"/api/users">();
55
+ expect(true).toBe(true);
56
+ });
57
+
58
+ it("should lowercase the method keys", () => {
59
+ const methods = new Hono().on("PATCH", "/users", (c) => c.json({ patched: true }));
60
+ type MethodsSchema = HonoAppToHyperFetch<typeof methods>;
61
+
62
+ expectTypeOf<keyof MethodsSchema["users"]>().toEqualTypeOf<"$patch">();
63
+ expect(true).toBe(true);
64
+ });
65
+
66
+ it("should resolve to an empty schema for anything that is not a Hono app", () => {
67
+ expectTypeOf<HonoAppToHyperFetch<{ routes: [] }>>().toEqualTypeOf<{}>();
68
+ expectTypeOf<HonoAppToHyperFetch<new () => Hono>>().toEqualTypeOf<{}>();
69
+ expect(true).toBe(true);
70
+ });
71
+
72
+ it("should reject routes the app does not define", () => {
73
+ // @ts-expect-error - no DELETE handler on /users
74
+ type MissingMethod = Schema["users"]["$delete"];
75
+ // @ts-expect-error - no /posts router is mounted
76
+ type MissingRoute = Schema["posts"];
77
+
78
+ expectTypeOf<MissingMethod>().toBeAny();
79
+ expectTypeOf<MissingRoute>().toBeAny();
80
+ expect(true).toBe(true);
81
+ });
82
+ });
83
+
84
+ describe("HonoAppToHyperFetch [ Request types ]", () => {
85
+ it("should take the response from the handler output", () => {
86
+ expectTypeOf<ExtractResponseType<Schema["users"]["$get"]>>().toEqualTypeOf<User[]>();
87
+ expectTypeOf<ExtractResponseType<Schema["auth"]["session"]["$delete"]>>().toEqualTypeOf<{ loggedOut: true }>();
88
+ expect(true).toBe(true);
89
+ });
90
+
91
+ it("should union the outputs of every status a handler returns", () => {
92
+ expectTypeOf<ExtractResponseType<Schema["users"]["$userId"]["$get"]>>().toEqualTypeOf<User | { message: string }>();
93
+ expect(true).toBe(true);
94
+ });
95
+
96
+ it("should take the payload from the json validator", () => {
97
+ expectTypeOf<ExtractPayloadType<Schema["users"]["$post"]>>().toEqualTypeOf<{ name: string }>();
98
+ expectTypeOf<ExtractPayloadType<Schema["users"]["$get"]>>().toEqualTypeOf<undefined>();
99
+ expect(true).toBe(true);
100
+ });
101
+
102
+ it("should take the query params from the query validator", () => {
103
+ expectTypeOf<ExtractQueryParamsType<Schema["users"]["$userId"]["posts"]["$get"]>>().toEqualTypeOf<{
104
+ page: string | string[];
105
+ }>();
106
+ expectTypeOf<ExtractQueryParamsType<Schema["users"]["$get"]>>().toEqualTypeOf<undefined>();
107
+ expect(true).toBe(true);
108
+ });
109
+
110
+ it("should leave the local error undefined", () => {
111
+ expectTypeOf<ExtractLocalErrorType<Schema["users"]["$get"]>>().toEqualTypeOf<undefined>();
112
+ expect(true).toBe(true);
113
+ });
114
+
115
+ it("should default the client to ClientInstance and accept a custom one", () => {
116
+ type AppClient = Client<{ code: string }, HttpAdapterType>;
117
+ type TypedSchema = HonoAppToHyperFetch<typeof app, AppClient>;
118
+
119
+ expectTypeOf<ExtractClientType<Schema["users"]["$get"]>>().toEqualTypeOf<ClientInstance>();
120
+ expectTypeOf<ExtractClientType<TypedSchema["users"]["$get"]>>().toEqualTypeOf<AppClient>();
121
+ expect(true).toBe(true);
122
+ });
123
+ });
124
+
125
+ describe("HonoAppToHyperFetch [ createSdk ]", () => {
126
+ const client = createClient({ url: "http://localhost" });
127
+ const sdk = createSdk<typeof client, Schema>(client);
128
+
129
+ it("should inject the SDK client into every request", () => {
130
+ expectTypeOf<ExtractClientType<typeof sdk.users.$get>>().toEqualTypeOf<typeof client>();
131
+ expect(true).toBe(true);
132
+ });
133
+
134
+ it("should apply the client's global error to every route", () => {
135
+ type ApiError = { message: string; code: string };
136
+ const errorClient = createClient<{ error: ApiError }>({ url: "http://localhost" });
137
+ const errorSdk = createSdk<typeof errorClient, Schema>(errorClient);
138
+
139
+ expectTypeOf<ExtractGlobalErrorType<typeof errorSdk.users.$get>>().toEqualTypeOf<ApiError>();
140
+ expect(true).toBe(true);
141
+ });
142
+
143
+ it("should type params from the Hono path", () => {
144
+ sdk.users.$userId.$get.setParams({ userId: "1" });
145
+ // @ts-expect-error - the Hono path names the param userId
146
+ sdk.users.$userId.$get.setParams({ id: "1" });
147
+ expect(true).toBe(true);
148
+ });
149
+
150
+ it("should type the payload from the json validator", () => {
151
+ sdk.users.$post.setPayload({ name: "Ann" });
152
+ // @ts-expect-error - the validator requires a string name
153
+ sdk.users.$post.setPayload({ name: 1 });
154
+ expect(true).toBe(true);
155
+ });
156
+
157
+ it("should type the query params from the query validator", () => {
158
+ sdk.users.$userId.posts.$get.setQueryParams({ page: "2" });
159
+ // @ts-expect-error - the validator reads page, not limit
160
+ sdk.users.$userId.posts.$get.setQueryParams({ limit: "2" });
161
+ expect(true).toBe(true);
162
+ });
163
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "noUnusedLocals": false,
6
+ "noUnusedParameters": false,
7
+ "types": ["vitest/globals", "@types/node"]
8
+ },
9
+ "include": ["**/*.ts", "**/*.tsx", "../../../global.d.ts", "../../../vitest.d.ts"],
10
+ "exclude": ["node_modules"]
11
+ }
@@ -0,0 +1,42 @@
1
+ import { Hono } from "hono";
2
+ import { validator } from "hono/validator";
3
+
4
+ export type User = { id: string; name: string };
5
+
6
+ const parseNewUser = (value: unknown): { name: string } => {
7
+ if (typeof value === "object" && value !== null && "name" in value && typeof value.name === "string") {
8
+ return { name: value.name };
9
+ }
10
+ throw new Error("Invalid user");
11
+ };
12
+
13
+ const parsePostsQuery = (value: Record<string, string | string[]>): { page: string } => {
14
+ const { page } = value;
15
+ return { page: typeof page === "string" ? page : "1" };
16
+ };
17
+
18
+ const users = new Hono()
19
+ .get("/", (c) => c.json<User[]>([{ id: "1", name: "Ann" }]))
20
+ .post("/", validator("json", parseNewUser), (c) => c.json<User>({ id: "2", name: c.req.valid("json").name }, 201))
21
+ .get("/:userId", (c) => {
22
+ const userId = c.req.param("userId");
23
+ if (userId === "missing") {
24
+ return c.json({ message: "User not found" }, 404);
25
+ }
26
+ return c.json<User>({ id: userId, name: "Ann" });
27
+ })
28
+ .get("/:userId/posts", validator("query", parsePostsQuery), (c) =>
29
+ c.json({ userId: c.req.param("userId"), page: c.req.valid("query").page }),
30
+ );
31
+
32
+ const auth = new Hono()
33
+ .get("/google-login", (c) => c.json({ authUrl: "https://accounts.example.com" }))
34
+ .delete("/session", (c) => c.json({ loggedOut: true }));
35
+
36
+ /** A Hono app with mounted routers, params, kebab-case paths, a JSON validator and a query validator. */
37
+ export const app = new Hono()
38
+ .get("/", (c) => c.json({ ok: true }))
39
+ .route("/users", users)
40
+ .route("/auth", auth);
41
+
42
+ export const apiApp = new Hono().basePath("/api").route("/users", users);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/hono",
3
- "version": "1.0.0",
3
+ "version": "9.8.1",
4
4
  "description": "Turn a Hono app type into a fully typed Hyper Fetch SDK schema",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",
@@ -57,5 +57,9 @@
57
57
  "rpc",
58
58
  "type-safe",
59
59
  "hyper fetch"
60
- ]
60
+ ],
61
+ "devDependencies": {
62
+ "@hono/node-server": "^2.1.9",
63
+ "hono": "^4.13.19"
64
+ }
61
65
  }
package/project.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "hono",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json"
4
+ }
@@ -0,0 +1,116 @@
1
+ import type { ClientInstance, Request } from "@hyper-fetch/core";
2
+ import type { HonoBase } from "hono/hono-base";
3
+
4
+ type Prettify<T> = {
5
+ [K in keyof T]: T[K];
6
+ } & {};
7
+
8
+ type UnionToIntersection<U> = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
9
+
10
+ /* -------------------------------------------------------------------------------------------------
11
+ * Hono schema -> flat record of requests
12
+ * -----------------------------------------------------------------------------------------------*/
13
+
14
+ /**
15
+ * `app.route()` returns a union of schemas. Merge it into one record keyed by path so that two
16
+ * routers registering methods on the same path end up on the same entry.
17
+ */
18
+ type UnionKeys<U> = U extends any ? keyof U : never;
19
+
20
+ type MergeUnionToRecord<U> = {
21
+ [K in UnionKeys<U> & string]: UnionToIntersection<U extends any ? (K extends keyof U ? U[K] : never) : never>;
22
+ };
23
+
24
+ type ExtractInput<T> = "input" extends keyof T ? T["input"] : undefined;
25
+ type ExtractOutput<T> = "output" extends keyof T ? T["output"] : undefined;
26
+ type ExtractJson<T> = "json" extends keyof T ? T["json"] : undefined;
27
+ type ExtractQuery<T> = "query" extends keyof T ? T["query"] : undefined;
28
+
29
+ /** Hono encodes methods as `$get`, `$post`, ... on every path entry of the schema. */
30
+ type ExtractMethodKeys<T> = Extract<keyof T, `$${string}`>;
31
+
32
+ /**
33
+ * Turns every `path -> { $method: endpoint }` entry of a Hono schema into a Hyper Fetch `Request`.
34
+ * The full Hono path is kept as the endpoint, so `:param` segments type `setParams()`.
35
+ */
36
+ type ConvertToRequest<Schema extends Record<string, any>, Client extends ClientInstance> = {
37
+ [Path in keyof Schema]: {
38
+ [K in ExtractMethodKeys<Schema[Path]> as K extends `$${infer M extends string}`
39
+ ? `$${Lowercase<M>}`
40
+ : never]: Request<
41
+ ExtractOutput<Schema[Path][K]>,
42
+ ExtractJson<ExtractInput<Schema[Path][K]>>,
43
+ ExtractQuery<ExtractInput<Schema[Path][K]>>,
44
+ undefined,
45
+ Path extends string ? Path : never,
46
+ Client
47
+ >;
48
+ };
49
+ };
50
+
51
+ /* -------------------------------------------------------------------------------------------------
52
+ * Flat record -> nested SDK schema
53
+ * -----------------------------------------------------------------------------------------------*/
54
+
55
+ type TrimStartSlash<S extends string> = S extends `/${infer R}` ? R : S;
56
+
57
+ type SplitPath<S extends string> = S extends ""
58
+ ? []
59
+ : S extends `${infer Head}/${infer Tail}`
60
+ ? [Head, ...SplitPath<Tail>]
61
+ : [S];
62
+
63
+ type CamelCase<S extends string> = S extends `${infer H}-${infer T}` ? `${H}${Capitalize<CamelCase<T>>}` : S;
64
+
65
+ /**
66
+ * `:userId` becomes `$userId` and `google-login` becomes `googleLogin`, matching the accessors
67
+ * `createSdk` resolves back to the endpoint at runtime.
68
+ */
69
+ type NormalizeSegment<S extends string> = S extends `:${infer P}` ? `$${P}` : CamelCase<S>;
70
+
71
+ type BuildNestedObject<Segments extends readonly string[], Value> = Segments extends [
72
+ infer Head extends string,
73
+ ...infer Rest extends string[],
74
+ ]
75
+ ? { [K in NormalizeSegment<Head>]: BuildNestedObject<Rest, Value> }
76
+ : Value;
77
+
78
+ type NestFlatRecord<R extends Record<string, any>> = Prettify<
79
+ UnionToIntersection<
80
+ {
81
+ [P in keyof R & string]: BuildNestedObject<SplitPath<TrimStartSlash<P>>, R[P]>;
82
+ }[keyof R & string]
83
+ >
84
+ >;
85
+
86
+ /**
87
+ * Converts the type of a Hono app into a Hyper Fetch SDK schema for `createSdk`.
88
+ *
89
+ * Every route becomes a `Request` whose response, JSON payload, query params and endpoint come
90
+ * from the Hono route definition and its validators. Path segments become nested properties,
91
+ * `:param` segments become `$param` properties, and kebab-case segments become camelCase.
92
+ *
93
+ * Pass the type of the app returned by your route chain, including apps mounted with
94
+ * `app.route()` and `basePath()`. Anything that is not a Hono app resolves to `{}`.
95
+ *
96
+ * @typeParam App - The Hono app type, usually `typeof app`.
97
+ * @typeParam Client - The client the requests belong to. `createSdk` injects its own client, so
98
+ * this is only needed when the schema is used outside of `createSdk`.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * // backend
103
+ * const app = new Hono().get("/users/:userId", (c) => c.json({ id: c.req.param("userId") }));
104
+ * export type AppSchema = HonoAppToHyperFetch<typeof app>;
105
+ *
106
+ * // frontend
107
+ * const sdk = createSdk<typeof client, AppSchema>(client);
108
+ * const { data } = await sdk.users.$userId.$get.send({ params: { userId: "1" } });
109
+ * ```
110
+ */
111
+ export type HonoAppToHyperFetch<App, Client extends ClientInstance = ClientInstance> =
112
+ // Match `HonoBase` with all four generics: `.route()` returns `HonoBase<E, S, BasePath, CurrentPath>`,
113
+ // so matching against `Hono<E, S, BasePath>` fails to infer the schema and resolves to `{}`.
114
+ App extends HonoBase<any, infer S, any, any>
115
+ ? Prettify<NestFlatRecord<ConvertToRequest<MergeUnionToRecord<S>, Client>>>
116
+ : {};
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export type { HonoAppToHyperFetch } from "./hono.types";
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "."
5
+ },
6
+ "exclude": ["node_modules", "dist", "vite.config.ts", "__tests__"]
7
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,31 @@
1
+ /// <reference types="vitest/config" />
2
+ import path from "path";
3
+ import { defineConfig } from "vite";
4
+ import dts from "vite-plugin-dts";
5
+ import tsconfigPaths from "vite-tsconfig-paths";
6
+
7
+ import { getRollupExternalsFromPackageJson } from "../../scripts/vite-lib-externals-from-package";
8
+
9
+ export default defineConfig({
10
+ build: {
11
+ lib: {
12
+ entry: "src/index.ts",
13
+ fileName: "index",
14
+ formats: ["es"],
15
+ },
16
+ minify: false,
17
+ rollupOptions: {
18
+ external: getRollupExternalsFromPackageJson(__dirname),
19
+ },
20
+ sourcemap: true,
21
+ },
22
+ plugins: [tsconfigPaths(), dts({ entryRoot: "src" })],
23
+ test: {
24
+ alias: {
25
+ "@hyper-fetch/core": path.resolve(__dirname, "../core/src/index.ts"),
26
+ },
27
+ environment: "node",
28
+ globals: true,
29
+ include: ["__tests__/**/*.spec.{ts,tsx}", "src/**/*.spec.{ts,tsx}"],
30
+ },
31
+ });
package/License.md DELETED
@@ -1,111 +0,0 @@
1
- Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
2
-
3
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
-
5
- 1. Definitions.
6
-
7
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9
8
- of this document.
9
-
10
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
11
-
12
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are
13
- under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or
14
- indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of
15
- fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
-
17
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
-
19
- "Source" form shall mean the preferred form for making modifications, including but not limited to software source code,
20
- documentation source, and configuration files.
21
-
22
- "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including
23
- but not limited to compiled object code, generated documentation, and conversions to other media types.
24
-
25
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as
26
- indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix
27
- below).
28
-
29
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work
30
- and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an
31
- original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain
32
- separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
33
-
34
- "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or
35
- additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the
36
- Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
37
- For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to
38
- the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code
39
- control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of
40
- discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in
41
- writing by the copyright owner as "Not a Contribution."
42
-
43
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received
44
- by Licensor and subsequently incorporated within the Work.
45
-
46
- 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to
47
- You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce,
48
- prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such
49
- Derivative Works in Source or Object form.
50
-
51
- 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a
52
- perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent
53
- license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license
54
- applies only to those patent claims licensable by such Contributor that are necessarily infringed by their
55
- Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was
56
- submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a
57
- lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory
58
- patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of
59
- the date such litigation is filed.
60
-
61
- 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
62
- or without modifications, and in Source or Object form, provided that You meet the following conditions:
63
-
64
- You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any
65
- modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of
66
- any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form
67
- of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a
68
- "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable
69
- copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any
70
- part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of
71
- the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a
72
- display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the
73
- NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices
74
- within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that
75
- such additional attribution notices cannot be construed as modifying the License.
76
-
77
- You may add Your own copyright statement to Your modifications and may provide additional or different license terms and
78
- conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole,
79
- provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this
80
- License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted
81
- for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any
82
- additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any
83
- separate license agreement you may have executed with Licensor regarding such Contributions.
84
-
85
- 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product
86
- names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
87
- reproducing the content of the NOTICE file.
88
-
89
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and
90
- each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
91
- either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
92
- MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
93
- of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this
94
- License.
95
-
96
- 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or
97
- otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing,
98
- shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or
99
- consequential damages of any character arising as a result of this License or out of the use or inability to use the
100
- Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or
101
- any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such
102
- damages.
103
-
104
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose
105
- to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or
106
- rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and
107
- on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and
108
- hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason
109
- of your accepting any such warranty or additional liability.
110
-
111
- END OF TERMS AND CONDITIONS