@buildinternet/releases-api-types 0.40.0 → 0.41.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/package.json +1 -1
- package/src/api-types.ts +8 -0
- package/src/schemas/listing.ts +32 -0
- package/src/schemas/well-known.test.ts +40 -0
- package/src/schemas/well-known.ts +11 -5
package/package.json
CHANGED
package/src/api-types.ts
CHANGED
|
@@ -350,6 +350,10 @@ export {
|
|
|
350
350
|
ClaimCheckOutcomeSchema,
|
|
351
351
|
ClaimVerifyResultSchema,
|
|
352
352
|
ListingClaimsResultSchema,
|
|
353
|
+
ListingPromoteBodySchema,
|
|
354
|
+
ListingPromoteLocatorOutcomeSchema,
|
|
355
|
+
ListingPromoteLocatorSchema,
|
|
356
|
+
ListingPromoteResultSchema,
|
|
353
357
|
type ListingValidateBody,
|
|
354
358
|
type ListingActivateBody,
|
|
355
359
|
type ListingIssue,
|
|
@@ -364,6 +368,10 @@ export {
|
|
|
364
368
|
type ClaimCheckOutcome,
|
|
365
369
|
type ClaimVerifyResult,
|
|
366
370
|
type ListingClaimsResult,
|
|
371
|
+
type ListingPromoteBody,
|
|
372
|
+
type ListingPromoteLocatorOutcome,
|
|
373
|
+
type ListingPromoteLocator,
|
|
374
|
+
type ListingPromoteResult,
|
|
367
375
|
} from "./schemas/listing.js";
|
|
368
376
|
export {
|
|
369
377
|
SourceListItemSchema,
|
package/src/schemas/listing.ts
CHANGED
|
@@ -136,3 +136,35 @@ export const ListingClaimsResultSchema = z.strictObject({
|
|
|
136
136
|
claims: z.array(OrgClaimSchema),
|
|
137
137
|
});
|
|
138
138
|
export type ListingClaimsResult = z.infer<typeof ListingClaimsResultSchema>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Self-serve Tier-1 promotion (#1947 epic item 3, PR B): a verified owner
|
|
142
|
+
* promotes their claimed stub to `tracked`. Independent of the internal
|
|
143
|
+
* materialization plan — this is the stable public projection.
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
export const ListingPromoteBodySchema = z.strictObject({
|
|
147
|
+
domain: z.string().min(1).max(255),
|
|
148
|
+
});
|
|
149
|
+
export type ListingPromoteBody = z.infer<typeof ListingPromoteBodySchema>;
|
|
150
|
+
|
|
151
|
+
export const ListingPromoteLocatorOutcomeSchema = z.enum(["live", "queued-for-review"]);
|
|
152
|
+
export type ListingPromoteLocatorOutcome = z.infer<typeof ListingPromoteLocatorOutcomeSchema>;
|
|
153
|
+
|
|
154
|
+
export const ListingPromoteLocatorSchema = z.strictObject({
|
|
155
|
+
locator: z.string(),
|
|
156
|
+
outcome: ListingPromoteLocatorOutcomeSchema,
|
|
157
|
+
});
|
|
158
|
+
export type ListingPromoteLocator = z.infer<typeof ListingPromoteLocatorSchema>;
|
|
159
|
+
|
|
160
|
+
export const ListingPromoteResultSchema = z.strictObject({
|
|
161
|
+
promoted: z.boolean(),
|
|
162
|
+
/** Present and true only for the idempotent already-`tracked` no-op. */
|
|
163
|
+
alreadyTracked: z.boolean().optional(),
|
|
164
|
+
sources: z.strictObject({
|
|
165
|
+
created: z.number(),
|
|
166
|
+
matched: z.number(),
|
|
167
|
+
}),
|
|
168
|
+
locators: z.array(ListingPromoteLocatorSchema),
|
|
169
|
+
});
|
|
170
|
+
export type ListingPromoteResult = z.infer<typeof ListingPromoteResultSchema>;
|
|
@@ -41,6 +41,7 @@ describe("releases.json v2 schemas", () => {
|
|
|
41
41
|
docs: "https://docs.acme.com/cloud",
|
|
42
42
|
support: "https://acme.com/support",
|
|
43
43
|
social: { twitter: "acmecloud" },
|
|
44
|
+
tags: ["ci", "cloud"],
|
|
44
45
|
archived: true,
|
|
45
46
|
releases: [{ github: "acme/cloud", canonical: true }],
|
|
46
47
|
},
|
|
@@ -56,9 +57,33 @@ describe("releases.json v2 schemas", () => {
|
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
expect(parsed.products?.[0]?.kind).toBe("future-kind");
|
|
60
|
+
expect(parsed.products?.[0]?.tags).toEqual(["ci", "cloud"]);
|
|
59
61
|
expect(parsed.registries?.["example.com"]).toEqual({ anything: "goes" });
|
|
60
62
|
});
|
|
61
63
|
|
|
64
|
+
it("accepts product-level tags and enforces the same bounds as org tags", () => {
|
|
65
|
+
expect(
|
|
66
|
+
ReleasesJsonDomainSchema.safeParse({
|
|
67
|
+
version: 2,
|
|
68
|
+
products: [{ name: "Cloud", tags: ["analytics", "sdk"] }],
|
|
69
|
+
}).success,
|
|
70
|
+
).toBe(true);
|
|
71
|
+
// too many tags (> 50)
|
|
72
|
+
expect(
|
|
73
|
+
ReleasesJsonDomainSchema.safeParse({
|
|
74
|
+
version: 2,
|
|
75
|
+
products: [{ name: "Cloud", tags: Array.from({ length: 51 }, (_, i) => `tag-${i}`) }],
|
|
76
|
+
}).success,
|
|
77
|
+
).toBe(false);
|
|
78
|
+
// empty tag string
|
|
79
|
+
expect(
|
|
80
|
+
ReleasesJsonDomainSchema.safeParse({
|
|
81
|
+
version: 2,
|
|
82
|
+
products: [{ name: "Cloud", tags: [""] }],
|
|
83
|
+
}).success,
|
|
84
|
+
).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
62
87
|
it("accepts the repo variant including github self", () => {
|
|
63
88
|
expect(
|
|
64
89
|
ReleasesJsonRepoSchema.safeParse({
|
|
@@ -70,6 +95,21 @@ describe("releases.json v2 schemas", () => {
|
|
|
70
95
|
).toBe(true);
|
|
71
96
|
});
|
|
72
97
|
|
|
98
|
+
it("requires https for locator URLs and avatar", () => {
|
|
99
|
+
expect(
|
|
100
|
+
ReleasesJsonDomainSchema.safeParse({ version: 2, releases: [{ url: "https://acme.com/x" }] })
|
|
101
|
+
.success,
|
|
102
|
+
).toBe(true);
|
|
103
|
+
expect(
|
|
104
|
+
ReleasesJsonDomainSchema.safeParse({ version: 2, releases: [{ url: "http://acme.com/x" }] })
|
|
105
|
+
.success,
|
|
106
|
+
).toBe(false);
|
|
107
|
+
expect(
|
|
108
|
+
ReleasesJsonDomainSchema.safeParse({ version: 2, avatar: "http://acme.com/logo.png" })
|
|
109
|
+
.success,
|
|
110
|
+
).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
|
|
73
113
|
it("requires the version 2 literal with no v1 compatibility", () => {
|
|
74
114
|
expect(ReleasesJsonConfigSchema.safeParse({ releases: [location(1)] }).success).toBe(false);
|
|
75
115
|
expect(ReleasesJsonConfigSchema.safeParse({ version: 1 }).success).toBe(false);
|
|
@@ -8,9 +8,14 @@ const MAX_FILE_RELEASES = 32;
|
|
|
8
8
|
const SocialValueSchema = z.string().min(1).max(200);
|
|
9
9
|
const SocialSchema = z.record(z.string().min(1).max(40), SocialValueSchema);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// `z.url().startsWith(...)` keeps the runtime URL + https check AND serializes to
|
|
12
|
+
// JSON Schema as `format: "uri"` + `pattern: "^https://"` — so the generated
|
|
13
|
+
// public schema rejects non-https schemes too (a plain `.refine()` would be
|
|
14
|
+
// silently dropped by z.toJSONSchema).
|
|
15
|
+
const HttpsUrlSchema = z.url().startsWith("https://", "locator must be an https URL");
|
|
16
|
+
|
|
17
|
+
/** Shared tag-array bounds — kept identical for org-level and product-level tags. */
|
|
18
|
+
const TagsSchema = z.array(z.string().min(1).max(60)).max(50);
|
|
14
19
|
|
|
15
20
|
const ReleaseLocationFields = {
|
|
16
21
|
url: HttpsUrlSchema.optional(),
|
|
@@ -87,6 +92,7 @@ export const ReleasesJsonProductSchema = z.strictObject({
|
|
|
87
92
|
docs: z.url().optional(),
|
|
88
93
|
support: z.url().optional(),
|
|
89
94
|
social: SocialSchema.optional(),
|
|
95
|
+
tags: TagsSchema.optional(),
|
|
90
96
|
archived: z.boolean().optional(),
|
|
91
97
|
releases: DomainProductReleasesSchema.optional(),
|
|
92
98
|
});
|
|
@@ -138,7 +144,7 @@ export const ReleasesJsonDomainSchema = z
|
|
|
138
144
|
description: z.string().max(2000).optional(),
|
|
139
145
|
category: z.string().min(1).max(120).optional(),
|
|
140
146
|
avatar: HttpsUrlSchema.optional(),
|
|
141
|
-
tags:
|
|
147
|
+
tags: TagsSchema.optional(),
|
|
142
148
|
social: SocialSchema.optional(),
|
|
143
149
|
products: z.array(ReleasesJsonProductSchema).max(MAX_PRODUCTS).optional(),
|
|
144
150
|
})
|
|
@@ -184,7 +190,7 @@ export const CreateStubOrgBodySchema = z.strictObject({
|
|
|
184
190
|
description: z.string().max(2000).optional(),
|
|
185
191
|
category: z.string().min(1).max(120).optional(),
|
|
186
192
|
avatar: HttpsUrlSchema.optional(),
|
|
187
|
-
tags:
|
|
193
|
+
tags: TagsSchema.optional(),
|
|
188
194
|
social: SocialSchema.optional(),
|
|
189
195
|
products: z.array(ReleasesJsonProductSchema).max(MAX_PRODUCTS).optional(),
|
|
190
196
|
releases: DomainReleasesSchema.optional(),
|