Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps/web/lib/products.ts
blob: adb481fecc6f6b443c2a1b8f9e3027811436976a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later

import { catalogMessages, type CatalogMessages } from "./catalog-messages.ts";
import type { Locale } from "./localization";

export { catalogMessages, type CatalogMessages } from "./catalog-messages.ts";

/**
 * The projects of product.progmasoft.com, in the order the catalog lists
 * them. Each has a page there; the catalog introduces it and leads on.
 */
export const productSlugs = [
  "tazel",
  "catch3",
  "agenceland",
  "archer",
  "etincelle",
] as const;
export type ProductSlug = (typeof productSlugs)[number];

export function isProductSlug(value: string): value is ProductSlug {
  return productSlugs.includes(value as ProductSlug);
}

export const productCategories = [
  "build",
  "testing",
  "ide",
  "data-format",
  "data-processing",
] as const;
export type ProductCategory = (typeof productCategories)[number];

export const productLanguages = [
  "C++",
  "Java",
  "Kotlin",
  "TypeScript",
] as const;
export type ProductLanguage = (typeof productLanguages)[number];

/** `released` once a version is out; `development` before the first one. */
export const productStatuses = ["released", "development"] as const;
export type ProductStatus = (typeof productStatuses)[number];

export interface ProductRelease {
  version: string;
  /** The day it was published, as YYYY-MM-DD. */
  date: string;
  url: string;
}

export interface ProductFacts {
  name: string;
  /** The project's own site, when it has one. */
  site?: string;
  /** The public source repository. */
  source: string;
  issues: string;
  /** An SPDX license expression. */
  license: string;
  language: ProductLanguage;
  category: ProductCategory;
  status: ProductStatus;
  /** The day its repository was created, as YYYY-MM-DD. */
  started: string;
  /** The newest release, when there is one. */
  latestRelease?: ProductRelease;
  accent: "violet" | "blue" | "green" | "orange" | "teal" | "slate";
}

function github(name: string) {
  return {
    source: `https://github.com/Progmasoft/${name}`,
    issues: `https://github.com/Progmasoft/${name}/issues`,
  };
}

export const products: Record<ProductSlug, ProductFacts> = {
  tazel: {
    name: "Tazel",
    site: "https://tazel.net/",
    ...github("tazel"),
    license: "MIT",
    language: "Kotlin",
    category: "build",
    status: "development",
    started: "2026-11-12",
    accent: "orange",
  },
  catch3: {
    name: "Catch3",
    site: "https://catch3.uk/",
    ...github("catch3"),
    // Files from Catch2 keep the Boost licence; Progmasoft's own files are
    // LGPL-3.0-or-later from 0.5.0 on.
    license: "BSL-1.0 AND LGPL-3.0-or-later",
    language: "C++",
    category: "testing",
    status: "released",
    started: "2026-09-24",
    latestRelease: {
      version: "0.4.0",
      date: "2026-11-15",
      url: "https://github.com/Progmasoft/catch3/releases/tag/catch3-0.4.0",
    },
    accent: "green",
  },
  agenceland: {
    name: "Agenceland",
    ...github("agenceland"),
    license: "MIT",
    language: "TypeScript",
    category: "ide",
    status: "development",
    started: "2026-11-13",
    accent: "violet",
  },
  archer: {
    name: "Archer",
    ...github("archer"),
    license: "MIT",
    language: "Java",
    category: "data-format",
    status: "development",
    started: "2026-11-14",
    accent: "blue",
  },
  etincelle: {
    name: "Etincelle",
    ...github("etincelle"),
    license: "MIT",
    language: "Java",
    category: "data-processing",
    status: "development",
    started: "2026-11-14",
    accent: "teal",
  },
};

export function getCatalogMessages(locale: Locale): CatalogMessages {
  return catalogMessages[locale];
}

/** What the catalog's search form asks for; an empty field asks for anything. */
export interface ProductFilter {
  query: string;
  category?: ProductCategory;
  language?: ProductLanguage;
  status?: ProductStatus;
}

function one(value: string | string[] | undefined): string {
  return (Array.isArray(value) ? value[0] : value)?.trim() ?? "";
}

function member<T extends string>(
  values: readonly T[],
  value: string,
): T | undefined {
  return values.includes(value as T) ? (value as T) : undefined;
}

/**
 * The filter of the catalog's query string: `q`, `category`, `language` and
 * `status`. A value the catalog does not know is the same as no value.
 */
export function parseProductFilter(
  search: Record<string, string | string[] | undefined>,
): ProductFilter {
  return {
    query: one(search.q).slice(0, 100),
    category: member(productCategories, one(search.category)),
    language: member(productLanguages, one(search.language)),
    status: member(productStatuses, one(search.status)),
  };
}

/**
 * The projects that match `filter`, in catalog order. The query matches the
 * name, the category, the tagline and the description in `locale`, without
 * regard to case.
 */
export function filterProducts(
  locale: Locale,
  filter: ProductFilter,
): ProductSlug[] {
  const messages = getCatalogMessages(locale);
  const query = filter.query.toLocaleLowerCase(locale);
  return productSlugs.filter((slug) => {
    const product = products[slug];
    if (filter.category && product.category !== filter.category) {
      return false;
    }
    if (filter.language && product.language !== filter.language) {
      return false;
    }
    if (filter.status && product.status !== filter.status) {
      return false;
    }
    if (query === "") {
      return true;
    }
    const text = messages.products[slug];
    return [
      product.name,
      messages.categories[product.category],
      text.tagline,
      text.description,
    ].some((field) => field.toLocaleLowerCase(locale).includes(query));
  });
}

/** The releases of every project, newest first. */
export function releases(): { slug: ProductSlug; release: ProductRelease }[] {
  return productSlugs
    .flatMap((slug) => {
      const release = products[slug].latestRelease;
      return release ? [{ slug, release }] : [];
    })
    .sort((a, b) => b.release.date.localeCompare(a.release.date));
}