@nxgt/typespec 0.9.1 → 0.10.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.
Files changed (81) hide show
  1. package/README.md +40 -9
  2. package/docs/README.md +1 -0
  3. package/docs/guide/columns.md +25 -11
  4. package/docs/guide/scalars.md +288 -0
  5. package/docs/roadmap.md +14 -0
  6. package/docs/troubleshooting.md +94 -2
  7. package/lib/scalars/color/hex-color-code.tsp +17 -0
  8. package/lib/scalars/color/hsl.tsp +18 -0
  9. package/lib/scalars/color/hsla.tsp +18 -0
  10. package/lib/scalars/color/rgb.tsp +18 -0
  11. package/lib/scalars/color/rgba.tsp +18 -0
  12. package/lib/scalars/color.tsp +6 -0
  13. package/lib/scalars/date-time/date-time.tsp +19 -0
  14. package/lib/scalars/date-time/date.tsp +17 -0
  15. package/lib/scalars/date-time/iso-duration.tsp +17 -0
  16. package/lib/scalars/date-time/local-date-time.tsp +15 -0
  17. package/lib/scalars/date-time/local-time.tsp +15 -0
  18. package/lib/scalars/date-time/time-zone.tsp +18 -0
  19. package/lib/scalars/date-time/time.tsp +17 -0
  20. package/lib/scalars/date-time/timestamp.tsp +15 -0
  21. package/lib/scalars/date-time/utc-offset.tsp +15 -0
  22. package/lib/scalars/date-time.tsp +10 -0
  23. package/lib/scalars/encoding/base64-url.tsp +17 -0
  24. package/lib/scalars/encoding/base64.tsp +18 -0
  25. package/lib/scalars/encoding/hexadecimal.tsp +15 -0
  26. package/lib/scalars/encoding/jwt.tsp +19 -0
  27. package/lib/scalars/encoding/sha256.tsp +16 -0
  28. package/lib/scalars/encoding/sha512.tsp +16 -0
  29. package/lib/scalars/encoding.tsp +7 -0
  30. package/lib/scalars/finance/currency.tsp +17 -0
  31. package/lib/scalars/finance/iban.tsp +19 -0
  32. package/lib/scalars/finance.tsp +3 -0
  33. package/lib/scalars/geo/latitude.tsp +14 -0
  34. package/lib/scalars/geo/longitude.tsp +14 -0
  35. package/lib/scalars/geo.tsp +3 -0
  36. package/lib/scalars/identifier/cuid2.tsp +17 -0
  37. package/lib/scalars/identifier/guid.tsp +12 -0
  38. package/lib/scalars/identifier/isbn.tsp +18 -0
  39. package/lib/scalars/identifier/ksuid.tsp +18 -0
  40. package/lib/scalars/identifier/nano-id.tsp +16 -0
  41. package/lib/scalars/identifier/object-id.tsp +16 -0
  42. package/lib/scalars/identifier/sem-ver.tsp +17 -0
  43. package/lib/scalars/identifier/ulid.tsp +17 -0
  44. package/lib/scalars/identifier/uuid-v4.tsp +16 -0
  45. package/lib/scalars/identifier/uuid-v7.tsp +16 -0
  46. package/lib/scalars/identifier/uuid.tsp +18 -0
  47. package/lib/scalars/identifier/xid.tsp +17 -0
  48. package/lib/scalars/identifier.tsp +13 -0
  49. package/lib/scalars/locale/country-code.tsp +17 -0
  50. package/lib/scalars/locale/locale.tsp +20 -0
  51. package/lib/scalars/locale.tsp +3 -0
  52. package/lib/scalars/network/cidr-v4.tsp +19 -0
  53. package/lib/scalars/network/cidr-v6.tsp +18 -0
  54. package/lib/scalars/network/email-address.tsp +20 -0
  55. package/lib/scalars/network/hostname.tsp +21 -0
  56. package/lib/scalars/network/http-url.tsp +21 -0
  57. package/lib/scalars/network/ip-v4.tsp +17 -0
  58. package/lib/scalars/network/ip-v6.tsp +18 -0
  59. package/lib/scalars/network/ip.tsp +17 -0
  60. package/lib/scalars/network/mac.tsp +16 -0
  61. package/lib/scalars/network/phone-number.tsp +18 -0
  62. package/lib/scalars/network.tsp +11 -0
  63. package/lib/scalars/number/big-int.tsp +15 -0
  64. package/lib/scalars/number/long.tsp +17 -0
  65. package/lib/scalars/number/negative-float.tsp +13 -0
  66. package/lib/scalars/number/negative-int.tsp +15 -0
  67. package/lib/scalars/number/non-negative-float.tsp +13 -0
  68. package/lib/scalars/number/non-negative-int.tsp +15 -0
  69. package/lib/scalars/number/non-positive-float.tsp +13 -0
  70. package/lib/scalars/number/non-positive-int.tsp +15 -0
  71. package/lib/scalars/number/port.tsp +14 -0
  72. package/lib/scalars/number/positive-float.tsp +13 -0
  73. package/lib/scalars/number/positive-int.tsp +15 -0
  74. package/lib/scalars/number/safe-int.tsp +16 -0
  75. package/lib/scalars/number.tsp +13 -0
  76. package/lib/scalars/string/emoji.tsp +21 -0
  77. package/lib/scalars/string/non-empty-string.tsp +15 -0
  78. package/lib/scalars/string.tsp +3 -0
  79. package/lib/scalars/value.tsp +2 -0
  80. package/lib/scalars.tsp +13 -12
  81. package/package.json +4 -4
@@ -0,0 +1,20 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A well-formed BCP 47 language tag in canonical case, kept as sent, at most
9
+ * 255 characters: `fr`, `fr-FR`, `zh-Hant-TW`, `en-US-u-ca-buddhist`. The
10
+ * language is lowercase, a script Titlecase, a region uppercase, the rest
11
+ * lowercase. The order of extensions and of `-u-` keywords is not in the
12
+ * pattern, nor is the IANA registry.
13
+ *
14
+ * Specified by https://www.rfc-editor.org/rfc/rfc5646.
15
+ */
16
+ @friendlyName("Locale")
17
+ @format("locale")
18
+ @pattern("^(?=.{1,255}$)[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}|\\d{3}))?(?:-(?:[a-z0-9]{5,8}|\\d[a-z0-9]{3}))*(?:-[0-9a-wyz](?:-[a-z0-9]{2,8})+)*(?:-x(?:-[a-z0-9]{1,8})+)?$")
19
+ @extension("x-nxgt-scalar", "Locale")
20
+ scalar locale extends string;
@@ -0,0 +1,3 @@
1
+ // The locale scalars, one file each under ./locale/.
2
+ import "./locale/country-code.tsp";
3
+ import "./locale/locale.tsp";
@@ -0,0 +1,19 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An IPv4 block in CIDR notation: a dotted-quad address, `/` and a prefix
9
+ * length from 0 to 32, kept as sent: `10.0.0.0/8`. Each part of the address
10
+ * is 0 to 255 with no leading zero. The address need not be the first of the
11
+ * block.
12
+ *
13
+ * Specified by https://www.rfc-editor.org/rfc/rfc4632.
14
+ */
15
+ @friendlyName("CIDRv4")
16
+ @format("cidr-v4")
17
+ @pattern("^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)/(?:3[0-2]|[12]?\\d)$")
18
+ @extension("x-nxgt-scalar", "CIDRv4")
19
+ scalar cidrV4 extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An IPv6 block in CIDR notation: an IPv6 address, `/` and a prefix length
9
+ * from 0 to 128, kept as sent: `2001:db8::/32`. The address takes every RFC
10
+ * 4291 text form, in any case, with no zone, and is not normalised.
11
+ *
12
+ * Specified by https://www.rfc-editor.org/rfc/rfc4291.
13
+ */
14
+ @friendlyName("CIDRv6")
15
+ @format("cidr-v6")
16
+ @pattern("^(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|(?:[0-9a-fA-F]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|::(?:[0-9a-fA-F]{1,4}:){0,5}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){1}:(?:[0-9a-fA-F]{1,4}:){0,4}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){2}:(?:[0-9a-fA-F]{1,4}:){0,3}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){3}:(?:[0-9a-fA-F]{1,4}:){0,2}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){4}:(?:[0-9a-fA-F]{1,4}:){0,1}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){5}:(?:[0-9a-fA-F]{1,4}:){0,0}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d))/(?:12[0-8]|1[01]\\d|[1-9]?\\d)$")
17
+ @extension("x-nxgt-scalar", "CIDRv6")
18
+ scalar cidrV6 extends string;
@@ -0,0 +1,20 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An e-mail address, in any case, kept as sent: `ada@example.com`. The local
9
+ * part is letters, digits, `_`, `'`, `+`, `-` and dots between them, with no
10
+ * quoted form; the domain is at least two labels, as `hostname` takes them,
11
+ * the last of letters or `xn--`. Only the shape is checked.
12
+ */
13
+ @friendlyName("EmailAddress")
14
+ @format("email")
15
+ @pattern("^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+\\-]@(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+(?:[A-Za-z]{2,63}|xn--[A-Za-z0-9-]{1,59})$")
16
+ @extension("x-nxgt-scalar", "EmailAddress")
17
+ scalar emailAddress extends string;
18
+
19
+ /** `emailAddress`, under the name @nxgt/typespec gave it first. */
20
+ alias email = emailAddress;
@@ -0,0 +1,21 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A host name, kept as sent: `api.example.com`. Dot-separated labels of
9
+ * letters, digits and hyphens, none starting or ending with a hyphen, each
10
+ * up to 63 characters and 253 in all, with an optional trailing dot. The
11
+ * last label is not a number (all digits, or `0x` and hex digits), so an
12
+ * IPv4 address is not a host name. A single label (`localhost`) and punycode
13
+ * are; a Unicode label is not. Nothing is resolved.
14
+ *
15
+ * Specified by https://www.rfc-editor.org/rfc/rfc1123.
16
+ */
17
+ @friendlyName("Hostname")
18
+ @format("hostname")
19
+ @pattern("^(?=.{1,253}\\.?$)(?!(?:[A-Za-z0-9-]+\\.)*(?:\\d+|0[xX][0-9a-fA-F]*)\\.?$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)*[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.?$")
20
+ @extension("x-nxgt-scalar", "Hostname")
21
+ scalar hostname extends string;
@@ -0,0 +1,21 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An absolute `http:` or `https:` URL, kept as sent:
9
+ * `https://example.com/a?b=c`. The scheme is lowercase; the host is a
10
+ * `hostname`, a canonical IPv4 address or a bracketed IPv6 address, with no
11
+ * user info; a port is digits with no leading zero. No white space, control
12
+ * or invisible format character anywhere. Other schemes (`javascript:`,
13
+ * `data:`) are refused. Named `httpUrl`, as `url` is a TypeSpec built-in.
14
+ *
15
+ * Specified by https://url.spec.whatwg.org/.
16
+ */
17
+ @friendlyName("URL")
18
+ @format("uri")
19
+ @pattern("^https?://(?:(?=[A-Za-z0-9.-]{1,253}(?:[:/?#]|$))(?!(?:[A-Za-z0-9-]+\\.)*(?:\\d+|0[xX][0-9a-fA-F]*)\\.?(?:[:/?#]|$))(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)*[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.?|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|\\[(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|(?:[0-9a-fA-F]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3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x-nxgt-scalar", "URL")
21
+ scalar httpUrl extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An IPv4 address in dotted-quad form: `192.168.0.1`. Each part is 0 to 255
9
+ * with no leading zero.
10
+ *
11
+ * Specified by https://www.rfc-editor.org/rfc/rfc791.
12
+ */
13
+ @friendlyName("IPv4")
14
+ @format("ipv4")
15
+ @pattern("^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$")
16
+ @extension("x-nxgt-scalar", "IPv4")
17
+ scalar ipV4 extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An IPv6 address in any RFC 4291 text form, in any case, kept as sent and
9
+ * never normalised: `2001:db8::1`, `::1`, `::ffff:192.0.2.1`. No zone
10
+ * (`%eth0`).
11
+ *
12
+ * Specified by https://www.rfc-editor.org/rfc/rfc4291.
13
+ */
14
+ @friendlyName("IPv6")
15
+ @format("ipv6")
16
+ @pattern("^(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|:(?:(?::[0-9a-fA-F]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xgt;
6
+
7
+ /**
8
+ * An IPv4 or an IPv6 address, as `ipV4` and `ipV6` take them, kept as sent:
9
+ * `192.168.0.1`, `2001:db8::1`.
10
+ *
11
+ * Specified by https://www.rfc-editor.org/rfc/rfc4291.
12
+ */
13
+ @friendlyName("IP")
14
+ @format("ip")
15
+ @pattern("^(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|(?:[0-9a-fA-F]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|::(?:[0-9a-fA-F]{1,4}:){0,5}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){1}:(?:[0-9a-fA-F]{1,4}:){0,4}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){2}:(?:[0-9a-fA-F]{1,4}:){0,3}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){3}:(?:[0-9a-fA-F]{1,4}:){0,2}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){4}:(?:[0-9a-fA-F]{1,4}:){0,1}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)|(?:[0-9a-fA-F]{1,4}:){5}:(?:[0-9a-fA-F]{1,4}:){0,0}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)))$")
16
+ @extension("x-nxgt-scalar", "IP")
17
+ scalar ip extends string;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A 48-bit MAC address: six hex pairs separated by `:`, in any case, kept as
9
+ * sent: `00:1a:2b:3c:4d:5e`. The IEEE hyphen form and the dotted form are
10
+ * refused.
11
+ */
12
+ @friendlyName("MAC")
13
+ @format("mac")
14
+ @pattern("^(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$")
15
+ @extension("x-nxgt-scalar", "MAC")
16
+ scalar mac extends string;
@@ -0,0 +1,18 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A phone number in E.164 form: `+`, a country code that does not start with
9
+ * 0, and 7 to 15 digits in all, with no space or separator: `+33612345678`.
10
+ * Only the shape is checked.
11
+ *
12
+ * Specified by https://www.itu.int/rec/T-REC-E.164.
13
+ */
14
+ @friendlyName("PhoneNumber")
15
+ @format("phone-number")
16
+ @pattern("^\\+[1-9]\\d{6,14}$")
17
+ @extension("x-nxgt-scalar", "PhoneNumber")
18
+ scalar phoneNumber extends string;
@@ -0,0 +1,11 @@
1
+ // The network scalars, one file each under ./network/.
2
+ import "./network/cidr-v4.tsp";
3
+ import "./network/cidr-v6.tsp";
4
+ import "./network/email-address.tsp";
5
+ import "./network/hostname.tsp";
6
+ import "./network/http-url.tsp";
7
+ import "./network/ip.tsp";
8
+ import "./network/ip-v4.tsp";
9
+ import "./network/ip-v6.tsp";
10
+ import "./network/mac.tsp";
11
+ import "./network/phone-number.tsp";
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer of any size, written as a canonical decimal string: no leading
9
+ * zero, no `+`, no `-0`, no spaces: `"123456789012345678901234567890"`.
10
+ */
11
+ @friendlyName("BigInt")
12
+ @format("big-int")
13
+ @pattern("^(?:0|-?[1-9]\\d*)$")
14
+ @extension("x-nxgt-scalar", "BigInt")
15
+ scalar bigInt extends string;
@@ -0,0 +1,17 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A signed 64-bit integer, -9223372036854775808 to 9223372036854775807, written
9
+ * as a canonical decimal string, since JSON numbers lose precision past 2^53:
10
+ * `"9223372036854775807"`. No leading zero, no `+`, no `-0`; the range is in
11
+ * the pattern.
12
+ */
13
+ @friendlyName("Long")
14
+ @format("int64")
15
+ @pattern("^(?:0|[1-9]\\d{0,17}|[1-8]\\d{18}|9[0-1]\\d{17}|92[0-1]\\d{16}|922[0-2]\\d{15}|9223[0-2]\\d{14}|92233[0-6]\\d{13}|922337[0-1]\\d{12}|92233720[0-2]\\d{10}|922337203[0-5]\\d{9}|9223372036[0-7]\\d{8}|92233720368[0-4]\\d{7}|922337203685[0-3]\\d{6}|9223372036854[0-6]\\d{5}|92233720368547[0-6]\\d{4}|922337203685477[0-4]\\d{3}|9223372036854775[0-7]\\d{2}|922337203685477580[0-7]|-[1-9]\\d{0,17}|-(?:[1-8]\\d{18}|9[0-1]\\d{17}|92[0-1]\\d{16}|922[0-2]\\d{15}|9223[0-2]\\d{14}|92233[0-6]\\d{13}|922337[0-1]\\d{12}|92233720[0-2]\\d{10}|922337203[0-5]\\d{9}|9223372036[0-7]\\d{8}|92233720368[0-4]\\d{7}|922337203685[0-3]\\d{6}|9223372036854[0-6]\\d{5}|92233720368547[0-6]\\d{4}|922337203685477[0-4]\\d{3}|9223372036854775[0-7]\\d{2}|922337203685477580[0-8]))$")
16
+ @extension("x-nxgt-scalar", "Long")
17
+ scalar long extends string;
@@ -0,0 +1,13 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A finite number below 0.
9
+ */
10
+ @friendlyName("NegativeFloat")
11
+ @maxValueExclusive(0)
12
+ @extension("x-nxgt-scalar", "NegativeFloat")
13
+ scalar negativeFloat extends float64;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer, as GraphQL's `Int` writes it: no float, whole or not, and no
9
+ * `-0`, which JSON Schema cannot express. From -2147483648 to -1.
10
+ */
11
+ @friendlyName("NegativeInt")
12
+ @minValue(-2147483648)
13
+ @maxValue(-1)
14
+ @extension("x-nxgt-scalar", "NegativeInt")
15
+ scalar negativeInt extends int32;
@@ -0,0 +1,13 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A finite number, 0 or above.
9
+ */
10
+ @friendlyName("NonNegativeFloat")
11
+ @minValue(0)
12
+ @extension("x-nxgt-scalar", "NonNegativeFloat")
13
+ scalar nonNegativeFloat extends float64;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer, as GraphQL's `Int` writes it: no float, whole or not, and no
9
+ * `-0`, which JSON Schema cannot express. From 0 to 2147483647.
10
+ */
11
+ @friendlyName("NonNegativeInt")
12
+ @minValue(0)
13
+ @maxValue(2147483647)
14
+ @extension("x-nxgt-scalar", "NonNegativeInt")
15
+ scalar nonNegativeInt extends int32;
@@ -0,0 +1,13 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A finite number, 0 or below.
9
+ */
10
+ @friendlyName("NonPositiveFloat")
11
+ @maxValue(0)
12
+ @extension("x-nxgt-scalar", "NonPositiveFloat")
13
+ scalar nonPositiveFloat extends float64;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer, as GraphQL's `Int` writes it: no float, whole or not, and no
9
+ * `-0`, which JSON Schema cannot express. From -2147483648 to 0.
10
+ */
11
+ @friendlyName("NonPositiveInt")
12
+ @minValue(-2147483648)
13
+ @maxValue(0)
14
+ @extension("x-nxgt-scalar", "NonPositiveInt")
15
+ scalar nonPositiveInt extends int32;
@@ -0,0 +1,14 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A TCP or UDP port, an integer from 0 to 65535.
9
+ */
10
+ @friendlyName("Port")
11
+ @minValue(0)
12
+ @maxValue(65535)
13
+ @extension("x-nxgt-scalar", "Port")
14
+ scalar port extends int32;
@@ -0,0 +1,13 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A finite number above 0.
9
+ */
10
+ @friendlyName("PositiveFloat")
11
+ @minValueExclusive(0)
12
+ @extension("x-nxgt-scalar", "PositiveFloat")
13
+ scalar positiveFloat extends float64;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer, as GraphQL's `Int` writes it: no float, whole or not, and no
9
+ * `-0`, which JSON Schema cannot express. From 1 to 2147483647.
10
+ */
11
+ @friendlyName("PositiveInt")
12
+ @minValue(1)
13
+ @maxValue(2147483647)
14
+ @extension("x-nxgt-scalar", "PositiveInt")
15
+ scalar positiveInt extends int32;
@@ -0,0 +1,16 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * An integer, as GraphQL's `Int` writes it: no float, whole or not, and no
9
+ * `-0`, which JSON Schema cannot express. From -9007199254740991 to
10
+ * 9007199254740991, the integers JavaScript holds exactly.
11
+ */
12
+ @friendlyName("SafeInt")
13
+ @minValue(-9007199254740991)
14
+ @maxValue(9007199254740991)
15
+ @extension("x-nxgt-scalar", "SafeInt")
16
+ scalar safeInt extends safeint;
@@ -0,0 +1,13 @@
1
+ // The number scalars, one file each under ./number/.
2
+ import "./number/big-int.tsp";
3
+ import "./number/long.tsp";
4
+ import "./number/negative-float.tsp";
5
+ import "./number/negative-int.tsp";
6
+ import "./number/non-negative-float.tsp";
7
+ import "./number/non-negative-int.tsp";
8
+ import "./number/non-positive-float.tsp";
9
+ import "./number/non-positive-int.tsp";
10
+ import "./number/port.tsp";
11
+ import "./number/positive-float.tsp";
12
+ import "./number/positive-int.tsp";
13
+ import "./number/safe-int.tsp";
@@ -0,0 +1,21 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * One emoji: `😀`, `👍🏽`, `👨‍👩‍👧`, `🇫🇷`, `1️⃣`. A pictograph with an optional variation
9
+ * selector or skin tone, joined to others by zero-width joiners; a
10
+ * pair of regional indicators (a flag); or a keycap. The pattern is an
11
+ * approximation by Unicode properties, so it needs the `u` flag; it does not
12
+ * segment user-perceived characters, takes no tag sequence (the flags of England,
13
+ * Scotland and Wales) and has no 32 code points limit.
14
+ *
15
+ * Specified by https://www.unicode.org/reports/tr51/.
16
+ */
17
+ @friendlyName("Emoji")
18
+ @format("emoji")
19
+ @pattern("^(?:\\p{Regional_Indicator}{2}|[#*0-9]\\uFE0F?\\u20E3|\\p{Extended_Pictographic}(?:\\uFE0F|\\p{Emoji_Modifier})?(?:\\u200D\\p{Extended_Pictographic}(?:\\uFE0F|\\p{Emoji_Modifier})?)*)$")
20
+ @extension("x-nxgt-scalar", "Emoji")
21
+ scalar emoji extends string;
@@ -0,0 +1,15 @@
1
+ import "@typespec/openapi";
2
+
3
+ using TypeSpec.OpenAPI;
4
+
5
+ namespace Nxgt;
6
+
7
+ /**
8
+ * A string with at least one non-white-space character, kept as sent, not
9
+ * trimmed. "White space" is ECMAScript's `\s`.
10
+ */
11
+ @friendlyName("NonEmptyString")
12
+ @format("non-empty-string")
13
+ @pattern("^\\s*\\S[\\s\\S]*$")
14
+ @extension("x-nxgt-scalar", "NonEmptyString")
15
+ scalar nonEmptyString extends string;
@@ -0,0 +1,3 @@
1
+ // The string scalars, one file each under ./string/.
2
+ import "./string/emoji.tsp";
3
+ import "./string/non-empty-string.tsp";
@@ -0,0 +1,2 @@
1
+ // The value scalars: none is declared, TypeSpec writes `unknown`,
2
+ // `Record<unknown>` and `void` (test/scalars/value.ts).
package/lib/scalars.tsp CHANGED
@@ -1,12 +1,13 @@
1
- namespace Nxgt;
2
-
3
- // The id @nxgt/drizzle's id() and actors() columns hold by default.
4
- /** A UUID, such as `0b8e5c1e-2f4a-4c3b-9d6e-7f8a9b0c1d2e`. */
5
- @friendlyName("Uuid")
6
- @format("uuid")
7
- scalar uuid extends string;
8
-
9
- /** An e-mail address. */
10
- @friendlyName("Email")
11
- @format("email")
12
- scalar email extends string;
1
+ // The scalars of @nxgt/graphql-scalars, one file per scalar under
2
+ // scalars/<category>/, each category imported by its own index.
3
+ import "./scalars/color.tsp";
4
+ import "./scalars/date-time.tsp";
5
+ import "./scalars/encoding.tsp";
6
+ import "./scalars/finance.tsp";
7
+ import "./scalars/geo.tsp";
8
+ import "./scalars/identifier.tsp";
9
+ import "./scalars/locale.tsp";
10
+ import "./scalars/network.tsp";
11
+ import "./scalars/number.tsp";
12
+ import "./scalars/string.tsp";
13
+ import "./scalars/value.tsp";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/typespec",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,11 +49,11 @@
49
49
  "@typespec/compiler": "^1.16.0",
50
50
  "@typespec/http": "^1.16.0",
51
51
  "@typespec/openapi": "^1.16.0",
52
- "typescript": "^6.0.3"
52
+ "typescript": "^6.0.3 || ^7.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@nxgt/openapi-codegen": "^0.5.1",
56
- "@nxgt/openapi-hono": "^0.3.0",
55
+ "@nxgt/openapi-codegen": "^0.8.0",
56
+ "@nxgt/openapi-hono": "^0.3.2",
57
57
  "@types/bun": "^1.4.0",
58
58
  "@typespec/compiler": "1.16.0",
59
59
  "@typespec/http": "1.16.0",