@qawolf/api-contracts 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ # @qawolf/api-contracts
2
+
3
+ Versioned contracts for the QA Wolf public API.
4
+
5
+ The package is the source of truth for public endpoints, and server implementations must derive their public input and output schemas from these contracts. Contract `name` values are exact tRPC route paths under the public namespace. Authorization and privileged request state stay in the owning server controller or policy.
6
+
7
+ ```ts
8
+ import { publicContractsV1 } from "@qawolf/api-contracts/v1";
9
+
10
+ const contract = publicContractsV1.run.create;
11
+ ```
12
+
13
+ Contracts are built by a factory that takes the id schemas as input. External consumers use `publicContractsV1`, which validates ids loosely (the server is the source of truth for id formats). The server instantiates `makeContractsV1` with its own strict id schemas, so the contract shape can never drift between the two sides while validation strictness stays server-owned.
14
+
15
+ This package must not depend on internal packages or expose internal concepts: it is published publicly.
16
+
17
+ ## Publishing
18
+
19
+ This package is intended to be published to the public npm registry so external repositories such as `qawolf/cli` can consume the public contracts. It is not published yet.
20
+
21
+ To publish a new version, bump `version` in `package.json` and run `npm publish` from this directory with an npm token authorized for the `@qawolf` scope (the build runs automatically via `prepublishOnly`).
@@ -0,0 +1,2 @@
1
+ export * from "./v1/index.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./v1/index.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { z } from "zod";
2
+ export type PublicApiContractKind = "read" | "write";
3
+ type AnyZodSchema = z.ZodType;
4
+ export type PublicApiContract<Name extends string, Kind extends PublicApiContractKind, Input extends AnyZodSchema, Output extends AnyZodSchema> = {
5
+ description: string;
6
+ input: Input;
7
+ kind: Kind;
8
+ name: Name;
9
+ output: Output;
10
+ };
11
+ export type AnyPublicApiContract = PublicApiContract<string, PublicApiContractKind, AnyZodSchema, AnyZodSchema>;
12
+ export {};
13
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/v1/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,KAAK,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC;AAE9B,MAAM,MAAM,iBAAiB,CAC3B,IAAI,SAAS,MAAM,EACnB,IAAI,SAAS,qBAAqB,EAClC,KAAK,SAAS,YAAY,EAC1B,MAAM,SAAS,YAAY,IACzB;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAClD,MAAM,EACN,qBAAqB,EACrB,YAAY,EACZ,YAAY,CACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/v1/definition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export type PublicIdSchema = z.ZodType<string, string>;
3
+ /**
4
+ * Id schemas injected into the contract factory, keyed by public API
5
+ * concept.
6
+ *
7
+ * The generic form exists because contract factories must stay generic over
8
+ * each schema individually: indexing a single generic record type loses the
9
+ * injected schema types (TypeScript resolves the indexed access to its
10
+ * constraint inside the factory body).
11
+ */
12
+ export type PublicIdSchemasOf<EnvironmentId extends PublicIdSchema, FlowId extends PublicIdSchema, RunId extends PublicIdSchema> = {
13
+ environment: EnvironmentId;
14
+ flow: FlowId;
15
+ run: RunId;
16
+ };
17
+ export type PublicIdSchemas = PublicIdSchemasOf<PublicIdSchema, PublicIdSchema, PublicIdSchema>;
18
+ /**
19
+ * The default schemas validate loosely: the server is the source of truth
20
+ * for id formats (including legacy formats), and encoding those rules here
21
+ * would leak internals. Server-side instantiations inject their own strict
22
+ * schemas instead.
23
+ */
24
+ export declare const defaultIdSchemas: PublicIdSchemas;
25
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/v1/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,CAC3B,aAAa,SAAS,cAAc,EACpC,MAAM,SAAS,cAAc,EAC7B,KAAK,SAAS,cAAc,IAC1B;IACF,WAAW,EAAE,aAAa,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAC7C,cAAc,EACd,cAAc,EACd,cAAc,CACf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAI9B,CAAC"}
package/dist/v1/ids.js ADDED
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The default schemas validate loosely: the server is the source of truth
4
+ * for id formats (including legacy formats), and encoding those rules here
5
+ * would leak internals. Server-side instantiations inject their own strict
6
+ * schemas instead.
7
+ */
8
+ export const defaultIdSchemas = {
9
+ environment: z.string().min(1).describe("The id of the environment."),
10
+ flow: z.string().min(1).describe("The id of the flow."),
11
+ run: z.string().min(1).describe("The id of the run."),
12
+ };
13
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/v1/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6BxB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACrE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACvD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC;CACtD,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { z } from "zod";
2
+ export type { AnyPublicApiContract, PublicApiContract, PublicApiContractKind, } from "./definition.js";
3
+ export { type PublicIdSchema, type PublicIdSchemas, defaultIdSchemas, } from "./ids.js";
4
+ import type { AnyPublicApiContract } from "./definition.js";
5
+ import { type PublicIdSchema, type PublicIdSchemasOf } from "./ids.js";
6
+ export type PublicApiInput<Api extends AnyPublicApiContract> = z.input<Api["input"]>;
7
+ export type PublicApiOutput<Api extends AnyPublicApiContract> = z.infer<Api["output"]>;
8
+ /**
9
+ * Builds the v1 contract catalog from a set of id schemas.
10
+ *
11
+ * External consumers use {@link publicContractsV1}. The server instantiates
12
+ * the same factory with its own strict id schemas, so the contract shape can
13
+ * never drift between the two while validation strictness stays server-owned.
14
+ */
15
+ export declare const makeContractsV1: <EnvironmentId extends PublicIdSchema, FlowId extends PublicIdSchema, RunId extends PublicIdSchema>(ids: PublicIdSchemasOf<EnvironmentId, FlowId, RunId>) => {
16
+ run: {
17
+ create: {
18
+ readonly description: "Create a run for selected flows in an environment.";
19
+ readonly input: z.ZodObject<{
20
+ environmentId: EnvironmentId;
21
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
22
+ flowIds: z.ZodArray<FlowId>;
23
+ ignoreRules: z.ZodDefault<z.ZodBoolean>;
24
+ }, z.core.$strip>;
25
+ readonly kind: "write";
26
+ readonly name: "run.create";
27
+ readonly output: z.ZodObject<{
28
+ runId: RunId;
29
+ }, z.core.$strip>;
30
+ };
31
+ };
32
+ };
33
+ export declare const publicContractsV1: {
34
+ run: {
35
+ create: {
36
+ readonly description: "Create a run for selected flows in an environment.";
37
+ readonly input: z.ZodObject<{
38
+ environmentId: PublicIdSchema;
39
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
40
+ flowIds: z.ZodArray<PublicIdSchema>;
41
+ ignoreRules: z.ZodDefault<z.ZodBoolean>;
42
+ }, z.core.$strip>;
43
+ readonly kind: "write";
44
+ readonly name: "run.create";
45
+ readonly output: z.ZodObject<{
46
+ runId: PublicIdSchema;
47
+ }, z.core.$strip>;
48
+ };
49
+ };
50
+ };
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEvB,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,cAAc,CAAC,GAAG,SAAS,oBAAoB,IAAI,CAAC,CAAC,KAAK,CACpE,GAAG,CAAC,OAAO,CAAC,CACb,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,GAAG,SAAS,oBAAoB,IAAI,CAAC,CAAC,KAAK,CACrE,GAAG,CAAC,QAAQ,CAAC,CACd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,aAAa,SAAS,cAAc,EACpC,MAAM,SAAS,cAAc,EAC7B,KAAK,SAAS,cAAc,EAE5B,KAAK,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC;;;;;;;;;;;;;;;;;CAKpD,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAAoC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export { defaultIdSchemas, } from "./ids.js";
2
+ import { defaultIdSchemas, } from "./ids.js";
3
+ import { makeCreateRunContract } from "./run/index.js";
4
+ /**
5
+ * Builds the v1 contract catalog from a set of id schemas.
6
+ *
7
+ * External consumers use {@link publicContractsV1}. The server instantiates
8
+ * the same factory with its own strict id schemas, so the contract shape can
9
+ * never drift between the two while validation strictness stays server-owned.
10
+ */
11
+ export const makeContractsV1 = (ids) => ({
12
+ run: {
13
+ create: makeCreateRunContract(ids),
14
+ },
15
+ });
16
+ export const publicContractsV1 = makeContractsV1(defaultIdSchemas);
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAGL,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAUvD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAK7B,GAAoD,EACpD,EAAE,CAAC,CAAC;IACJ,GAAG,EAAE;QACH,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC;KACnC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ import type { PublicIdSchema, PublicIdSchemasOf } from "../ids.js";
3
+ export declare const makeCreateRunContract: <EnvironmentId extends PublicIdSchema, FlowId extends PublicIdSchema, RunId extends PublicIdSchema>(ids: PublicIdSchemasOf<EnvironmentId, FlowId, RunId>) => {
4
+ readonly description: "Create a run for selected flows in an environment.";
5
+ readonly input: z.ZodObject<{
6
+ environmentId: EnvironmentId;
7
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
+ flowIds: z.ZodArray<FlowId>;
9
+ ignoreRules: z.ZodDefault<z.ZodBoolean>;
10
+ }, z.core.$strip>;
11
+ readonly kind: "write";
12
+ readonly name: "run.create";
13
+ readonly output: z.ZodObject<{
14
+ runId: RunId;
15
+ }, z.core.$strip>;
16
+ };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v1/run/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnE,eAAO,MAAM,qBAAqB,GAChC,aAAa,SAAS,cAAc,EACpC,MAAM,SAAS,cAAc,EAC7B,KAAK,SAAS,cAAc,EAE5B,KAAK,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC;;;;;;;;;;;;;CAsBrD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ export const makeCreateRunContract = (ids) => {
3
+ const input = z.object({
4
+ environmentId: ids.environment,
5
+ environmentVariables: z.record(z.string(), z.string()).optional(),
6
+ flowIds: z.array(ids.flow).min(1),
7
+ ignoreRules: z.boolean().default(false),
8
+ });
9
+ const output = z.object({ runId: ids.run });
10
+ return {
11
+ description: "Create a run for selected flows in an environment.",
12
+ input,
13
+ kind: "write",
14
+ name: "run.create",
15
+ output,
16
+ };
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v1/run/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAKnC,GAAoD,EACpD,EAAE;IACF,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;QACrB,aAAa,EAAE,GAAG,CAAC,WAAW;QAC9B,oBAAoB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACjE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;KACxC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAE5C,OAAO;QACL,WAAW,EAAE,oDAAoD;QACjE,KAAK;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,YAAY;QAClB,MAAM;KAMP,CAAC;AACJ,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@qawolf/api-contracts",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Versioned contracts for the QA Wolf public API",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/qawolf/platform.git"
9
+ },
10
+ "sideEffects": false,
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./v1": {
18
+ "types": "./dist/v1/index.d.ts",
19
+ "import": "./dist/v1/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "scripts": {
26
+ "build": "rm -rf ./dist && tsc -p tsconfig.build.json",
27
+ "lint:ci": "npm run lint:non-fixable; NON_FIXABLE_EXIT=$?; npm run lint:fixable && exit $NON_FIXABLE_EXIT",
28
+ "lint:dev": "npm run lint:fixable",
29
+ "lint:fixable": "eslint . --ext cjs,cts,js,jsx,mjs,ts,tsx --fix --quiet && prettier --log-level=warn --write .",
30
+ "lint:non-fixable": "dpdm --exit-code circular:1 --no-tree --no-warning --transform --include='.*' --exclude='/(dist|node_modules)/' '**/*'",
31
+ "prepublishOnly": "npm run build",
32
+ "test": "NODE_OPTIONS=\"--experimental-vm-modules\" NODE_NO_WARNINGS=1 jest",
33
+ "tsc:check": "tsgo --noEmit -p tsconfig.typecheck.json"
34
+ },
35
+ "dependencies": {
36
+ "tslib": "^2.5.3"
37
+ },
38
+ "devDependencies": {
39
+ "@typescript/native-preview": "^7.0.0-dev.20260416.1",
40
+ "typescript": "^5.9.2",
41
+ "zod": "^4.1.11"
42
+ },
43
+ "peerDependencies": {
44
+ "zod": "^4.1.11"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.22.0 <25"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ }
52
+ }