@qawolf/api-contracts 0.51.0 → 0.52.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.
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ import type { PublicIdSchema } from "../ids.js";
3
+ export declare const makeReportDeploymentStatusContract: <DeploymentId extends PublicIdSchema, EnvironmentId extends PublicIdSchema, WorkspaceId extends PublicIdSchema>(ids: {
4
+ deployment: DeploymentId;
5
+ environment: EnvironmentId;
6
+ workspace: WorkspaceId;
7
+ }) => {
8
+ readonly description: "Report a deployment lifecycle status. A deployment's first success report evaluates global triggers asynchronously, and it is the only report that does: a trigger added or unpaused later does not make an already reported deployment evaluate again. Report that deployment under a new providerDeploymentId to evaluate it against the current triggers. The response contains the deployment only, not the resulting runs. This route requires an organization or user API key.";
9
+ readonly input: z.ZodObject<{
10
+ deployTarget: z.ZodOptional<z.ZodURL>;
11
+ environment: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
12
+ id: EnvironmentId;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ baseEphemeralEnvironment: z.ZodOptional<z.ZodString>;
15
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
16
+ name: z.ZodString;
17
+ }, z.core.$strict>]>>;
18
+ environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
19
+ metadata: z.ZodOptional<z.ZodObject<{
20
+ commitSha: z.ZodOptional<z.ZodString>;
21
+ pullRequestNumber: z.ZodOptional<z.ZodNumber>;
22
+ ref: z.ZodOptional<z.ZodString>;
23
+ repository: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strict>>;
25
+ providerDeploymentId: z.ZodString;
26
+ status: z.ZodEnum<{
27
+ success: "success";
28
+ failure: "failure";
29
+ pending: "pending";
30
+ inactive: "inactive";
31
+ }>;
32
+ workspaceId: WorkspaceId;
33
+ }, z.core.$strict>;
34
+ readonly kind: "write";
35
+ readonly name: "deployment.reportStatus";
36
+ readonly output: z.ZodObject<{
37
+ deployment: z.ZodObject<{
38
+ id: DeploymentId;
39
+ status: z.ZodEnum<{
40
+ success: "success";
41
+ failure: "failure";
42
+ pending: "pending";
43
+ inactive: "inactive";
44
+ }>;
45
+ url: z.ZodURL;
46
+ }, z.core.$strip>;
47
+ }, z.core.$strip>;
48
+ };
49
+ //# sourceMappingURL=reportStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportStatus.d.ts","sourceRoot":"","sources":["../../../src/v1/deployment/reportStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAYhD,eAAO,MAAM,kCAAkC,GAC7C,YAAY,SAAS,cAAc,EACnC,aAAa,SAAS,cAAc,EACpC,WAAW,SAAS,cAAc,EAClC,KAAK;IACL,UAAU,EAAE,YAAY,CAAC;IACzB,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,WAAW,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwKA,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { z } from "zod";
2
+ import { resource } from "../resource.js";
3
+ // Shared by the input status field and the output resource status field so
4
+ // adding a status to one cannot silently drift from the other.
5
+ const deploymentStatusSchema = z.enum([
6
+ "pending",
7
+ "success",
8
+ "failure",
9
+ "inactive",
10
+ ]);
11
+ export const makeReportDeploymentStatusContract = (ids) => {
12
+ // Exactly one selector, expressed as a union rather than a refinement so the
13
+ // shape itself rules out sending both. Strict branches matter: a loose
14
+ // `z.object` strips unknown keys, so `{ id, name }` would match the first
15
+ // branch and silently discard the name the caller sent.
16
+ const environment = z.union([
17
+ z.strictObject({
18
+ id: ids.environment.describe("The id of an existing environment. Never creates an environment. Send an alias through name instead."),
19
+ }),
20
+ z.strictObject({
21
+ baseEphemeralEnvironment: z
22
+ .string()
23
+ .trim()
24
+ .min(1)
25
+ .max(255)
26
+ .describe("The alias or name of the environment a created ephemeral environment copies from. Only valid with ephemeral. The server uses the team default base environment when no environment matches this value.")
27
+ .optional(),
28
+ ephemeral: z
29
+ .boolean()
30
+ .describe("Requests an ephemeral environment when the name creates one. A name that matches an existing environment keeps that environment's kind.")
31
+ .optional(),
32
+ name: z
33
+ .string()
34
+ .trim()
35
+ .min(1)
36
+ .max(255)
37
+ .describe("The provider deploy environment name. Resolves an environment by alias or name; creates one when no match exists."),
38
+ }),
39
+ ], {
40
+ error: "Send environment as either { id } or { name }, with optional ephemeral and baseEphemeralEnvironment.",
41
+ });
42
+ const metadata = z
43
+ .strictObject({
44
+ commitSha: z
45
+ .string()
46
+ .trim()
47
+ .min(1)
48
+ .max(255)
49
+ .describe("The commit sha of the deployed application revision.")
50
+ .optional(),
51
+ // The deployer knows its pull request, so this is more reliable than the
52
+ // code host lookup the server otherwise runs against `commitSha`.
53
+ pullRequestNumber: z
54
+ .number()
55
+ .int()
56
+ .positive()
57
+ .describe("The number of the pull request the deployment belongs to. Requires repository.")
58
+ .optional(),
59
+ ref: z
60
+ .string()
61
+ .trim()
62
+ .min(1)
63
+ .max(255)
64
+ .describe("The branch or ref that was deployed.")
65
+ .optional(),
66
+ repository: z
67
+ .string()
68
+ .trim()
69
+ .min(1)
70
+ .max(255)
71
+ .describe('The owner/name of the repository, e.g. "acme/web".')
72
+ .optional(),
73
+ })
74
+ // A pull request number names a pull request within one repository, so it
75
+ // cannot be resolved without one.
76
+ .refine((value) => value.pullRequestNumber === undefined || value.repository !== undefined, {
77
+ message: "repository is required when pullRequestNumber is provided.",
78
+ path: ["pullRequestNumber"],
79
+ });
80
+ const input = z
81
+ .strictObject({
82
+ deployTarget: z
83
+ .httpUrl()
84
+ .max(2048)
85
+ .describe("The URL the deployment serves, e.g. a preview URL.")
86
+ .optional(),
87
+ // A deployment stays bound to the environment resolved on its first
88
+ // report, so later reports may omit the selector. Report a promotion as a
89
+ // new deployment with a new providerDeploymentId.
90
+ environment: environment
91
+ .describe("Selects the environment the deployment reports into.")
92
+ .optional(),
93
+ environmentVariables: z
94
+ .record(z.string(), z.string())
95
+ .describe("Environment variable overrides for the runs this deployment requests. A report that omits this field keeps the stored values. A report that sends it replaces them.")
96
+ .optional(),
97
+ metadata: metadata
98
+ .describe("Code host details for the deployed revision.")
99
+ .optional(),
100
+ providerDeploymentId: z
101
+ .string()
102
+ .trim()
103
+ .min(1)
104
+ .max(255)
105
+ .describe('Your identifier for the deployment, e.g. "vercel_dpl_123". Reports with the same providerDeploymentId update one deployment within this workspace.'),
106
+ status: deploymentStatusSchema.describe("The deployment lifecycle status. A deployment's first success report evaluates global triggers asynchronously, and it is the only report that does. The response does not include the resulting runs."),
107
+ workspaceId: ids.workspace.describe("The workspace to report the deployment status into."),
108
+ })
109
+ // Only a created ephemeral environment copies from a base, so the field has
110
+ // no meaning without `ephemeral`. The selector union cannot express this
111
+ // without a third branch, which would make every validation failure read as
112
+ // a three-way union error.
113
+ .superRefine((value, context) => {
114
+ if (value.environment !== undefined &&
115
+ "name" in value.environment &&
116
+ value.environment.baseEphemeralEnvironment !== undefined &&
117
+ value.environment.ephemeral !== true) {
118
+ context.addIssue({
119
+ code: "custom",
120
+ message: "baseEphemeralEnvironment is only valid with ephemeral.",
121
+ path: ["environment", "baseEphemeralEnvironment"],
122
+ });
123
+ }
124
+ });
125
+ const deployment = resource({
126
+ id: ids.deployment,
127
+ status: deploymentStatusSchema.describe("The status reported in this request."),
128
+ }, { urlFieldDescription: "Absolute URL of the environment's runs page." });
129
+ const output = z.object({ deployment });
130
+ return {
131
+ description: "Report a deployment lifecycle status. A deployment's first success report evaluates global triggers asynchronously, and it is the only report that does: a trigger added or unpaused later does not make an already reported deployment evaluate again. Report that deployment under a new providerDeploymentId to evaluate it against the current triggers. The response contains the deployment only, not the resulting runs. This route requires an organization or user API key.",
132
+ input,
133
+ kind: "write",
134
+ name: "deployment.reportStatus",
135
+ output,
136
+ };
137
+ };
138
+ //# sourceMappingURL=reportStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportStatus.js","sourceRoot":"","sources":["../../../src/v1/deployment/reportStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,2EAA2E;AAC3E,+DAA+D;AAC/D,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,SAAS;IACT,SAAS;IACT,SAAS;IACT,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAIhD,GAID,EAAE,EAAE;IACH,6EAA6E;IAC7E,uEAAuE;IACvE,0EAA0E;IAC1E,wDAAwD;IACxD,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CACzB;QACE,CAAC,CAAC,YAAY,CAAC;YACb,EAAE,EAAE,GAAG,CAAC,WAAW,CAAC,QAAQ,CAC1B,sGAAsG,CACvG;SACF,CAAC;QACF,CAAC,CAAC,YAAY,CAAC;YACb,wBAAwB,EAAE,CAAC;iBACxB,MAAM,EAAE;iBACR,IAAI,EAAE;iBACN,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,CACP,wMAAwM,CACzM;iBACA,QAAQ,EAAE;YACb,SAAS,EAAE,CAAC;iBACT,OAAO,EAAE;iBACT,QAAQ,CACP,yIAAyI,CAC1I;iBACA,QAAQ,EAAE;YACb,IAAI,EAAE,CAAC;iBACJ,MAAM,EAAE;iBACR,IAAI,EAAE;iBACN,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,CACP,mHAAmH,CACpH;SACJ,CAAC;KACH,EACD;QACE,KAAK,EACH,sGAAsG;KACzG,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC;SACf,YAAY,CAAC;QACZ,SAAS,EAAE,CAAC;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AAW,EACT,sdAAsd;QACxd,KAAK;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,yBAAyB;QAC/B,MAAM;KAMP,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qawolf/api-contracts",
3
- "version": "0.51.0",
3
+ "version": "0.52.0",
4
4
  "private": false,
5
5
  "description": "Versioned contracts for the QA Wolf public API",
6
6
  "repository": {