@buildinternet/releases-api-types 0.39.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildinternet/releases-api-types",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Wire protocol — request/response types for the Releases registry API. Shared by web, workers, and clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/api-types.ts CHANGED
@@ -342,12 +342,36 @@ export {
342
342
  ListingOrgPointerSchema,
343
343
  ListingValidationResultSchema,
344
344
  ListingActivateResultSchema,
345
+ ListingClaimBodySchema,
346
+ ListingClaimVerifyBodySchema,
347
+ OrgClaimStatusSchema,
348
+ ClaimMethodSchema,
349
+ OrgClaimSchema,
350
+ ClaimCheckOutcomeSchema,
351
+ ClaimVerifyResultSchema,
352
+ ListingClaimsResultSchema,
353
+ ListingPromoteBodySchema,
354
+ ListingPromoteLocatorOutcomeSchema,
355
+ ListingPromoteLocatorSchema,
356
+ ListingPromoteResultSchema,
345
357
  type ListingValidateBody,
346
358
  type ListingActivateBody,
347
359
  type ListingIssue,
348
360
  type ListingLocation,
349
361
  type ListingValidationResult,
350
362
  type ListingActivateResult,
363
+ type ListingClaimBody,
364
+ type ListingClaimVerifyBody,
365
+ type OrgClaimStatus,
366
+ type ClaimMethod,
367
+ type OrgClaim,
368
+ type ClaimCheckOutcome,
369
+ type ClaimVerifyResult,
370
+ type ListingClaimsResult,
371
+ type ListingPromoteBody,
372
+ type ListingPromoteLocatorOutcome,
373
+ type ListingPromoteLocator,
374
+ type ListingPromoteResult,
351
375
  } from "./schemas/listing.js";
352
376
  export {
353
377
  SourceListItemSchema,
@@ -74,3 +74,97 @@ export const ListingActivateResultSchema = z.strictObject({
74
74
  trackingRequested: z.boolean(),
75
75
  });
76
76
  export type ListingActivateResult = z.infer<typeof ListingActivateResultSchema>;
77
+
78
+ /**
79
+ * Ownership claim flow (#1947 epic item 2): a signed-in user proves control
80
+ * of a listed domain via a well-known token file OR a DNS TXT record.
81
+ */
82
+
83
+ export const ListingClaimBodySchema = z.strictObject({
84
+ domain: z.string().min(1).max(255),
85
+ });
86
+ export type ListingClaimBody = z.infer<typeof ListingClaimBodySchema>;
87
+
88
+ export const ListingClaimVerifyBodySchema = z.strictObject({
89
+ claimId: z.string().min(1),
90
+ });
91
+ export type ListingClaimVerifyBody = z.infer<typeof ListingClaimVerifyBodySchema>;
92
+
93
+ export const OrgClaimStatusSchema = z.enum(["pending", "verified", "expired"]);
94
+ export type OrgClaimStatus = z.infer<typeof OrgClaimStatusSchema>;
95
+
96
+ export const ClaimMethodSchema = z.enum(["well-known", "dns-txt"]);
97
+ export type ClaimMethod = z.infer<typeof ClaimMethodSchema>;
98
+
99
+ /**
100
+ * `token` + `instructions` are only present while the claim is `pending` (or
101
+ * on mint) — once verified there's nothing left to prove, and an expired
102
+ * claim's token is stale.
103
+ */
104
+ export const OrgClaimSchema = z.strictObject({
105
+ id: z.string(),
106
+ org: ListingOrgPointerSchema,
107
+ status: OrgClaimStatusSchema,
108
+ method: ClaimMethodSchema.optional(),
109
+ token: z.string().optional(),
110
+ createdAt: z.string(),
111
+ verifiedAt: z.string().optional(),
112
+ expiresAt: z.string(),
113
+ instructions: z
114
+ .strictObject({
115
+ wellKnownUrl: z.string(),
116
+ dnsRecordName: z.string(),
117
+ })
118
+ .optional(),
119
+ });
120
+ export type OrgClaim = z.infer<typeof OrgClaimSchema>;
121
+
122
+ export const ClaimCheckOutcomeSchema = z.enum(["ok", "mismatch", "unreachable"]);
123
+ export type ClaimCheckOutcome = z.infer<typeof ClaimCheckOutcomeSchema>;
124
+
125
+ export const ClaimVerifyResultSchema = z.strictObject({
126
+ verified: z.boolean(),
127
+ checked: z.strictObject({
128
+ wellKnown: ClaimCheckOutcomeSchema,
129
+ dnsTxt: ClaimCheckOutcomeSchema,
130
+ }),
131
+ claim: OrgClaimSchema,
132
+ });
133
+ export type ClaimVerifyResult = z.infer<typeof ClaimVerifyResultSchema>;
134
+
135
+ export const ListingClaimsResultSchema = z.strictObject({
136
+ claims: z.array(OrgClaimSchema),
137
+ });
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>;
@@ -171,6 +171,8 @@ export const SourceDetailSchema = z.object({
171
171
  latestDate: z.string().nullable(),
172
172
  lastFetchedAt: z.string().nullable(),
173
173
  lastPolledAt: z.string().nullable(),
174
+ // #1969: additive so pinned old workers/clients degrade gracefully.
175
+ changeDetectedAt: z.string().nullable().optional(),
174
176
  trackingSince: z.string(),
175
177
  releases: z.array(ReleaseItemSchema),
176
178
  pagination: SourceFeedPaginationSchema,
@@ -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
- const HttpsUrlSchema = z
12
- .url()
13
- .refine((url) => url.startsWith("https://"), "locator must be an https URL");
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: z.array(z.string().min(1).max(60)).max(50).optional(),
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: z.array(z.string().min(1).max(60)).max(50).optional(),
193
+ tags: TagsSchema.optional(),
188
194
  social: SocialSchema.optional(),
189
195
  products: z.array(ReleasesJsonProductSchema).max(MAX_PRODUCTS).optional(),
190
196
  releases: DomainReleasesSchema.optional(),