@workerstack/database 0.21.0 → 0.22.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 (82) hide show
  1. package/README.md +197 -33
  2. package/docs/meta-contract.md +55 -1
  3. package/package.json +1 -6
  4. package/src/codegen/analyzer-types.ts +6 -1
  5. package/src/codegen/annotations.ts +66 -9
  6. package/src/codegen/format-constraints.ts +114 -0
  7. package/src/codegen/generators/dtos/entity-file.ts +2 -1
  8. package/src/codegen/generators/dtos/example-meta.ts +22 -2
  9. package/src/codegen/generators/dtos/field-schema.ts +31 -8
  10. package/src/codegen/generators/dtos/ip-patterns.ts +25 -11
  11. package/src/codegen/generators/dtos/number-range.ts +22 -3
  12. package/src/codegen/generators/dtos/schema-aliases.ts +5 -3
  13. package/src/codegen/generators/dtos/text-format.ts +63 -0
  14. package/src/codegen/generators/dtos/text-schema.ts +49 -2
  15. package/src/codegen/generators/manifest.ts +9 -1
  16. package/src/codegen/runtime/read-comb.ts +71 -3
  17. package/src/codegen/runtime/read-tables.ts +31 -19
  18. package/src/codegen/runtime/snapshot-types.ts +3 -1
  19. package/src/codegen/runtime/to-meta.ts +6 -3
  20. package/src/formats/catalog.ts +255 -0
  21. package/src/formats/iana-time-zone.ts +117 -0
  22. package/src/formats/iso3166-1.ts +78 -0
  23. package/src/formats/iso4217.ts +42 -0
  24. package/src/formats/iso639-1.ts +41 -0
  25. package/src/formats/uts35.ts +143 -0
  26. package/src/index.ts +5 -0
  27. package/src/meta/column.ts +22 -9
  28. package/src/pg/columns.ts +6 -4
  29. package/src/sqlite/columns.ts +6 -4
  30. package/src/sqlite/constraints.ts +120 -6
  31. package/types/codegen/analyzer-types.d.ts +6 -1
  32. package/types/codegen/analyzer-types.d.ts.map +1 -1
  33. package/types/codegen/annotations.d.ts +12 -7
  34. package/types/codegen/annotations.d.ts.map +1 -1
  35. package/types/codegen/format-constraints.d.ts +22 -0
  36. package/types/codegen/format-constraints.d.ts.map +1 -0
  37. package/types/codegen/generators/dtos/entity-file.d.ts.map +1 -1
  38. package/types/codegen/generators/dtos/example-meta.d.ts.map +1 -1
  39. package/types/codegen/generators/dtos/field-schema.d.ts.map +1 -1
  40. package/types/codegen/generators/dtos/ip-patterns.d.ts +7 -0
  41. package/types/codegen/generators/dtos/ip-patterns.d.ts.map +1 -1
  42. package/types/codegen/generators/dtos/number-range.d.ts +8 -0
  43. package/types/codegen/generators/dtos/number-range.d.ts.map +1 -1
  44. package/types/codegen/generators/dtos/schema-aliases.d.ts +1 -1
  45. package/types/codegen/generators/dtos/schema-aliases.d.ts.map +1 -1
  46. package/types/codegen/generators/dtos/text-format.d.ts +31 -0
  47. package/types/codegen/generators/dtos/text-format.d.ts.map +1 -0
  48. package/types/codegen/generators/dtos/text-schema.d.ts +8 -1
  49. package/types/codegen/generators/dtos/text-schema.d.ts.map +1 -1
  50. package/types/codegen/generators/manifest.d.ts +5 -0
  51. package/types/codegen/generators/manifest.d.ts.map +1 -1
  52. package/types/codegen/runtime/read-comb.d.ts +17 -3
  53. package/types/codegen/runtime/read-comb.d.ts.map +1 -1
  54. package/types/codegen/runtime/read-tables.d.ts.map +1 -1
  55. package/types/codegen/runtime/snapshot-types.d.ts +3 -1
  56. package/types/codegen/runtime/snapshot-types.d.ts.map +1 -1
  57. package/types/codegen/runtime/to-meta.d.ts.map +1 -1
  58. package/types/formats/catalog.d.ts +51 -0
  59. package/types/formats/catalog.d.ts.map +1 -0
  60. package/types/formats/iana-time-zone.d.ts +7 -0
  61. package/types/formats/iana-time-zone.d.ts.map +1 -0
  62. package/types/formats/iso3166-1.d.ts +12 -0
  63. package/types/formats/iso3166-1.d.ts.map +1 -0
  64. package/types/formats/iso4217.d.ts +7 -0
  65. package/types/formats/iso4217.d.ts.map +1 -0
  66. package/types/formats/iso639-1.d.ts +6 -0
  67. package/types/formats/iso639-1.d.ts.map +1 -0
  68. package/types/formats/uts35.d.ts +13 -0
  69. package/types/formats/uts35.d.ts.map +1 -0
  70. package/types/index.d.ts +5 -0
  71. package/types/index.d.ts.map +1 -1
  72. package/types/meta/column.d.ts +7 -1
  73. package/types/meta/column.d.ts.map +1 -1
  74. package/types/pg/columns.d.ts +3 -3
  75. package/types/pg/columns.d.ts.map +1 -1
  76. package/types/sqlite/columns.d.ts +3 -3
  77. package/types/sqlite/columns.d.ts.map +1 -1
  78. package/types/sqlite/constraints.d.ts +117 -5
  79. package/types/sqlite/constraints.d.ts.map +1 -1
  80. package/src/sqlite/patterns.ts +0 -19
  81. package/types/sqlite/patterns.d.ts +0 -19
  82. package/types/sqlite/patterns.d.ts.map +0 -1
@@ -6,7 +6,7 @@
6
6
  import { type $Type, type HasDefault, type IsPrimaryKey, type NotNull } from "drizzle-orm";
7
7
  import { type SQLiteBooleanBuilder, type SQLiteIntegerBuilder, type SQLiteRealBuilder, type SQLiteTextBuilder, type SQLiteTextJsonBuilder } from "drizzle-orm/sqlite-core";
8
8
  import type * as z from "zod";
9
- import type { EnumOptions, IntegerConstraints, JsonConstraints, TextConstraints, TimestampConstraints } from "./constraints.ts";
9
+ import type { EnumOptions, IntegerConstraints, JsonConstraints, RealConstraints, RefConstraints, TextConstraints, TimestampConstraints } from "./constraints.ts";
10
10
  /** A SQLite TEXT column builder */
11
11
  type Text = SQLiteTextBuilder<[string, ...string[]]>;
12
12
  /** The names a creation timestamp may take, in either casing, so codegen recognizes it */
@@ -35,9 +35,9 @@ export type SqliteColumns = {
35
35
  /** a JSON value stored as TEXT, typed and validated by `schema` in the generated DTOs */
36
36
  json: <TSchema extends z.ZodTypeAny = z.ZodTypeAny>(name: string, _schema: TSchema, _constraints?: JsonConstraints) => $Type<SQLiteTextJsonBuilder, z.infer<TSchema>>;
37
37
  /** a floating-point REAL */
38
- real: (name: string, _constraints?: IntegerConstraints) => SQLiteRealBuilder;
38
+ real: (name: string, _constraints?: RealConstraints) => SQLiteRealBuilder;
39
39
  /** a TEXT foreign key; chain `.references()` to name the column it points at */
40
- ref: (name: string, _constraints?: TextConstraints) => Text;
40
+ ref: (name: string, _constraints?: RefConstraints) => Text;
41
41
  /** the auto-incrementing INTEGER primary key `id`, filled by the database */
42
42
  serialId: () => IsPrimaryKey<HasDefault<NotNull<SQLiteIntegerBuilder>>>;
43
43
  /** a TEXT column; a declared `max` also becomes its declared length */
@@ -1 +1 @@
1
- {"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/sqlite/columns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAO,MAAM,aAAa,CAAA;AAC/F,OAAO,EAGN,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAE1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAA;AAE7B,OAAO,KAAK,EACX,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,MAAM,kBAAkB,CAAA;AAOzB,mCAAmC;AACnC,KAAK,IAAI,GAAG,iBAAiB,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAA;AACpD,0FAA0F;AAC1F,KAAK,aAAa,GAAG,WAAW,GAAG,YAAY,CAAA;AAC/C,6FAA6F;AAC7F,KAAK,aAAa,GAAG,WAAW,GAAG,YAAY,CAAA;AAC/C,yFAAyF;AACzF,KAAK,aAAa,GAAG,WAAW,GAAG,YAAY,CAAA;AAE/C,wGAAwG;AACxG,MAAM,MAAM,aAAa,GAAG;IAC3B,6CAA6C;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,oBAAoB,CAAA;IAC/C,uGAAuG;IACvG,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,oBAAoB,KAAK,UAAU,CAAC,OAAO,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AAE,MAAM,EAAE,YAAY,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;IAC1D,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAA;IACvE,uEAAuE;IACvE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,eAAe,KAAK,IAAI,CAAA;IAC5D,kEAAkE;IAClE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,oBAAoB,KAAK,oBAAoB,CAAA;IACtF,mIAAmI;IACnI,SAAS,EAAE,CACV,IAAI,EAAE,aAAa,EACnB,YAAY,CAAC,EAAE,oBAAoB,KAC/B,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAA;CAC1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,CAAC,EAAE,aA+Df,CAAA"}
@@ -2,6 +2,9 @@
2
2
  * Type-safe column constraint definitions
3
3
  * These exist only in the type system and are completely erased at runtime
4
4
  */
5
+ import type * as z from "zod";
6
+ import type { IntegerFormat, TextFormat } from "../formats/catalog.ts";
7
+ /** What every helper's constraints take: the DTO, mutation, privacy, relation and tenant flags */
5
8
  type BaseConstraints = {
6
9
  /** Field is filled by comb or the database: generated create and update DTOs leave it out */
7
10
  autogenerate?: boolean | undefined;
@@ -77,12 +80,82 @@ type StringValidationConstraints = {
77
80
  * Text column constraints
78
81
  * Closed record - only these properties allowed
79
82
  */
80
- export type TextConstraints = BaseConstraints & StringTransformConstraints & NumericRangeConstraints & StringValidationConstraints;
83
+ export type TextConstraints = BaseConstraints & StringTransformConstraints & NumericRangeConstraints & StringValidationConstraints & {
84
+ /**
85
+ * The standard a written text holds: the generated DTOs run the format's trim and case, then hold the
86
+ * value to its pattern and, where it names one, its pinned registry, and publish the id as `x-comb-format`.
87
+ * A value it refuses is one zod `invalid_format` issue carrying the id, worded by zod's locale. One of:
88
+ * - `base64url`: RFC 4648 §5 base64url, unpadded; `dGVzdA`; pattern only
89
+ * - `bcp47`: BCP 47 language tag, RFC 5646 §2.1 well-formed; `zh-Hant-TW`; pattern only
90
+ * - `e164`: ITU-T E.164 phone number, + and up to 15 digits; `+385911234567`; pattern only
91
+ * - `iana-time-zone`: IANA time zone name, tzdata 2026f; `Europe/Zagreb`; registry
92
+ * - `ip`: IPv4 dotted quad or IPv6 address, RFC 4291 §2.2; `2001:db8::1`; pattern only
93
+ * - `ipv4`: IPv4 address, dotted quad without leading zeros; `192.0.2.1`; pattern only
94
+ * - `ipv6`: IPv6 address, RFC 4291 §2.2; `2001:db8::1`; pattern only
95
+ * - `iso3166-1-alpha-2`: ISO 3166-1 alpha-2 country code, Debian iso-codes v4.20.1; `HR`; registry
96
+ * - `iso3166-1-alpha-3`: ISO 3166-1 alpha-3 country code, Debian iso-codes v4.20.1; `HRV`; registry
97
+ * - `iso4217`: ISO 4217 alphabetic currency code, SIX list 2026-09-17; `EUR`; registry
98
+ * - `iso639-1`: ISO 639-1 language code, Debian iso-codes v4.20.1; `hr`; registry
99
+ * - `kebab-slug`: kebab-case slug, lowercase letters and digits joined by single hyphens; `spring-sale-2026`; pattern only
100
+ * - `pkce-s256-challenge`: RFC 7636 §4.2 PKCE SHA-256 code challenge; `E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM`; pattern only
101
+ * - `rfc1123-hostname`: RFC 1123 §2.1 host name; `api.example.com`; pattern only
102
+ * - `semver`: Semantic Versioning 2.0.0 version; `1.4.0-rc.1`; pattern only
103
+ * - `sha256-hex`: SHA-256 digest, FIPS 180-4, lowercase hex; `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`; pattern only
104
+ * - `sha512-hex`: SHA-512 digest, FIPS 180-4, lowercase hex; `cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e`; pattern only
105
+ * - `srgb-hex`: sRGB color as #rrggbb, CSS Color 4; `#1e90ff`; pattern only
106
+ * - `srgb-hex-alpha`: sRGB color with alpha as #rrggbbaa, CSS Color 4; `#1e90ff80`; pattern only
107
+ * - `ulid`: ULID, Crockford base32 in lowercase; `01hzy3k8q2m4n5p6r7s8t9v0wx`; pattern only
108
+ * - `uts35-ca`: UTS #35 calendar (ca) key value, CLDR 49; `gregory`; pattern only
109
+ * - `uts35-fw`: UTS #35 first day of the week (fw) key value, CLDR 49; `mon`; pattern only
110
+ * - `uts35-hc`: UTS #35 hour cycle (hc) key value, CLDR 49; `h23`; pattern only
111
+ * - `uts35-ms`: UTS #35 measurement system (ms) key value, CLDR 49; `metric`; pattern only
112
+ * - `uts35-mu`: UTS #35 measurement unit (mu) key value, CLDR 49; `celsius`; pattern only
113
+ * - `uts35-nu`: UTS #35 numbering system (nu) key value, CLDR 49; `latn`; pattern only
114
+ * - `uuid`: RFC 9562 UUID, lowercase hex; `0f8fad5b-d9cb-469f-a165-70867728950e`; pattern only
115
+ * - `uuid-v4`: RFC 9562 UUID version 4, lowercase hex; `0f8fad5b-d9cb-469f-a165-70867728950e`; pattern only
116
+ * - `uuid-v7`: RFC 9562 UUID version 7, lowercase hex; `01890a5d-ac96-774b-bcce-b302099a8057`; pattern only
117
+ */
118
+ format?: TextFormat | undefined;
119
+ /**
120
+ * An exported zod schema the generated DTOs pipe the value into after every other rule, on the
121
+ * transformed value; its issues reach the caller as zod yields them, and its input JSON Schema is
122
+ * published beside `x-comb-schema`. Codegen imports it as it imports a `c.json` schema, so export it
123
+ * from a module of its own, or above the table that names it
124
+ */
125
+ schema?: z.ZodType<string, string> | undefined;
126
+ };
127
+ /**
128
+ * Floating-point column constraints: its bounds, and an exported zod schema its value is piped into
129
+ * Closed record - only these properties allowed
130
+ */
131
+ export type RealConstraints = BaseConstraints & NumericRangeConstraints & {
132
+ /**
133
+ * An exported zod schema the generated DTOs pipe the value into after its bounds; its issues reach
134
+ * the caller as zod yields them, and its input JSON Schema is published beside `x-comb-schema`.
135
+ * Codegen imports it as it imports a `c.json` schema, so export it from a module of its own, or
136
+ * above the table that names it
137
+ */
138
+ schema?: z.ZodType<number, number> | undefined;
139
+ };
81
140
  /**
82
- * Integer/numeric column constraints
141
+ * Integer column constraints: a real's, and the standard `format` that numbers its values
83
142
  * Closed record - only these properties allowed
84
143
  */
85
- export type IntegerConstraints = BaseConstraints & NumericRangeConstraints;
144
+ export type IntegerConstraints = RealConstraints & {
145
+ /**
146
+ * The standard that numbers the value: its range bounds the generated DTOs, the tighter of it and a
147
+ * declared `min` or `max` winning, and they publish the id as `x-comb-format`. One of:
148
+ * - `iso8601-month`: ISO 8601 month number, 1 January to 12 December; `3`
149
+ * - `iso8601-weekday`: ISO 8601 §3.2.2 weekday number, 1 Monday to 7 Sunday; `1`
150
+ */
151
+ format?: IntegerFormat | undefined;
152
+ };
153
+ /**
154
+ * Foreign key column constraints: a text's but `format` and `schema`, as the value is another
155
+ * table's key, held to that key's own rules
156
+ * Closed record - only these properties allowed
157
+ */
158
+ export type RefConstraints = Omit<TextConstraints, "format" | "schema">;
86
159
  /**
87
160
  * JSON column constraints
88
161
  * Closed record - only these properties allowed
@@ -113,7 +186,46 @@ export type EnumStates<TState extends string = string> = {
113
186
  readonly [K in TState]?: readonly TState[] | undefined;
114
187
  } | undefined;
115
188
  };
116
- /** What `c.enum` takes beside its values: its state machine, and the `nomutate`, `private` and `tenant` flags every helper takes */
117
- export type EnumOptions<TState extends string = string> = EnumStates<TState> & Pick<BaseConstraints, "nomutate" | "private" | "tenant">;
189
+ /**
190
+ * What `c.enum` takes beside its values: its state machine, the `nomutate`, `private` and `tenant`
191
+ * flags every helper takes, and the standard `format` its values are written in, which codegen holds
192
+ * each value to and publishes as `x-comb-format`
193
+ */
194
+ export type EnumOptions<TState extends string = string> = EnumStates<TState> & Pick<BaseConstraints, "nomutate" | "private" | "tenant"> & {
195
+ /**
196
+ * The standard the values are written in: codegen refuses a value the format does not take as written,
197
+ * and the DTOs publish the id as `x-comb-format`; the values stay the rule. One of:
198
+ * - `base64url`: RFC 4648 §5 base64url, unpadded; `dGVzdA`; pattern only
199
+ * - `bcp47`: BCP 47 language tag, RFC 5646 §2.1 well-formed; `zh-Hant-TW`; pattern only
200
+ * - `e164`: ITU-T E.164 phone number, + and up to 15 digits; `+385911234567`; pattern only
201
+ * - `iana-time-zone`: IANA time zone name, tzdata 2026f; `Europe/Zagreb`; registry
202
+ * - `ip`: IPv4 dotted quad or IPv6 address, RFC 4291 §2.2; `2001:db8::1`; pattern only
203
+ * - `ipv4`: IPv4 address, dotted quad without leading zeros; `192.0.2.1`; pattern only
204
+ * - `ipv6`: IPv6 address, RFC 4291 §2.2; `2001:db8::1`; pattern only
205
+ * - `iso3166-1-alpha-2`: ISO 3166-1 alpha-2 country code, Debian iso-codes v4.20.1; `HR`; registry
206
+ * - `iso3166-1-alpha-3`: ISO 3166-1 alpha-3 country code, Debian iso-codes v4.20.1; `HRV`; registry
207
+ * - `iso4217`: ISO 4217 alphabetic currency code, SIX list 2026-09-17; `EUR`; registry
208
+ * - `iso639-1`: ISO 639-1 language code, Debian iso-codes v4.20.1; `hr`; registry
209
+ * - `kebab-slug`: kebab-case slug, lowercase letters and digits joined by single hyphens; `spring-sale-2026`; pattern only
210
+ * - `pkce-s256-challenge`: RFC 7636 §4.2 PKCE SHA-256 code challenge; `E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM`; pattern only
211
+ * - `rfc1123-hostname`: RFC 1123 §2.1 host name; `api.example.com`; pattern only
212
+ * - `semver`: Semantic Versioning 2.0.0 version; `1.4.0-rc.1`; pattern only
213
+ * - `sha256-hex`: SHA-256 digest, FIPS 180-4, lowercase hex; `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`; pattern only
214
+ * - `sha512-hex`: SHA-512 digest, FIPS 180-4, lowercase hex; `cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e`; pattern only
215
+ * - `srgb-hex`: sRGB color as #rrggbb, CSS Color 4; `#1e90ff`; pattern only
216
+ * - `srgb-hex-alpha`: sRGB color with alpha as #rrggbbaa, CSS Color 4; `#1e90ff80`; pattern only
217
+ * - `ulid`: ULID, Crockford base32 in lowercase; `01hzy3k8q2m4n5p6r7s8t9v0wx`; pattern only
218
+ * - `uts35-ca`: UTS #35 calendar (ca) key value, CLDR 49; `gregory`; pattern only
219
+ * - `uts35-fw`: UTS #35 first day of the week (fw) key value, CLDR 49; `mon`; pattern only
220
+ * - `uts35-hc`: UTS #35 hour cycle (hc) key value, CLDR 49; `h23`; pattern only
221
+ * - `uts35-ms`: UTS #35 measurement system (ms) key value, CLDR 49; `metric`; pattern only
222
+ * - `uts35-mu`: UTS #35 measurement unit (mu) key value, CLDR 49; `celsius`; pattern only
223
+ * - `uts35-nu`: UTS #35 numbering system (nu) key value, CLDR 49; `latn`; pattern only
224
+ * - `uuid`: RFC 9562 UUID, lowercase hex; `0f8fad5b-d9cb-469f-a165-70867728950e`; pattern only
225
+ * - `uuid-v4`: RFC 9562 UUID version 4, lowercase hex; `0f8fad5b-d9cb-469f-a165-70867728950e`; pattern only
226
+ * - `uuid-v7`: RFC 9562 UUID version 7, lowercase hex; `01890a5d-ac96-774b-bcce-b302099a8057`; pattern only
227
+ */
228
+ format?: TextFormat | undefined;
229
+ };
118
230
  export {};
119
231
  //# sourceMappingURL=constraints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/sqlite/constraints.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,KAAK,eAAe,GAAG;IACtB,6FAA6F;IAC7F,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,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GAIG;AACH,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,GAC3E,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC,GAAG;IAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;CAC/B,CAAA"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Shared regex patterns for table field constraints.
3
- * Used as `pattern` values in c.text() definitions.
4
- *
5
- * These are source-level strings read by the codegen parser —
6
- * backslashes are doubled so the generated .regex() output is correct.
7
- */
8
- const patterns = {
9
- /** ISO 3166-1 alpha-2 country code (e.g. "US", "DE") */
10
- COUNTRY_ALPHA2: "/^[A-Z]{2}$/",
11
- /** E.164 international phone number (e.g. "+14155552671") */
12
- E164_PHONE: "/^\\+[1-9][0-9]{7,14}$/",
13
- /** IANA timezone (e.g. "America/New_York", "Europe/Berlin") */
14
- IANA_TIMEZONE: "/^[A-Za-z_/]+$/",
15
- /** BCP 47 language tag, base or with region (e.g. "en", "pt-BR") */
16
- LOCALE: "/^[a-z]{2}(-[A-Z]{2})?$/",
17
- } as const
18
-
19
- export { patterns }
@@ -1,19 +0,0 @@
1
- /**
2
- * Shared regex patterns for table field constraints.
3
- * Used as `pattern` values in c.text() definitions.
4
- *
5
- * These are source-level strings read by the codegen parser —
6
- * backslashes are doubled so the generated .regex() output is correct.
7
- */
8
- declare const patterns: {
9
- /** ISO 3166-1 alpha-2 country code (e.g. "US", "DE") */
10
- readonly COUNTRY_ALPHA2: "/^[A-Z]{2}$/";
11
- /** E.164 international phone number (e.g. "+14155552671") */
12
- readonly E164_PHONE: "/^\\+[1-9][0-9]{7,14}$/";
13
- /** IANA timezone (e.g. "America/New_York", "Europe/Berlin") */
14
- readonly IANA_TIMEZONE: "/^[A-Za-z_/]+$/";
15
- /** BCP 47 language tag, base or with region (e.g. "en", "pt-BR") */
16
- readonly LOCALE: "/^[a-z]{2}(-[A-Z]{2})?$/";
17
- };
18
- export { patterns };
19
- //# sourceMappingURL=patterns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/sqlite/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ;IACb,wDAAwD;aACxD,cAAc,EAAE,cAAc;IAC9B,6DAA6D;aAC7D,UAAU,EAAE,yBAAyB;IACrC,+DAA+D;aAC/D,aAAa,EAAE,iBAAiB;IAChC,oEAAoE;aACpE,MAAM,EAAE,0BAA0B;CACzB,CAAA;AAEV,OAAO,EAAE,QAAQ,EAAE,CAAA"}