@m1212e/rumble 0.26.4 → 0.27.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/out/index.cjs +5937 -84
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +144 -35
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +144 -36
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +5929 -85
- package/out/index.mjs.map +1 -1
- package/package.json +2 -2
package/out/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { One, SQL, Table } from "drizzle-orm";
|
|
3
2
|
import { GraphQLError, GraphQLScalarType, GraphQLSchema } from "graphql";
|
|
4
3
|
import { Tracer } from "@opentelemetry/api";
|
|
@@ -9,6 +8,7 @@ import { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
|
9
8
|
import { MySqlAsyncDatabase } from "drizzle-orm/mysql-core";
|
|
10
9
|
import { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
|
|
11
10
|
import SchemaBuilder from "@pothos/core";
|
|
11
|
+
import { z } from "zod";
|
|
12
12
|
import { PhoneNumber } from "libphonenumber-js";
|
|
13
13
|
import { IncomingMessage, RequestListener, ServerResponse } from "node:http";
|
|
14
14
|
import { Http2ServerRequest, Http2ServerResponse } from "node:http2";
|
|
@@ -450,41 +450,6 @@ export declare const assertFirstEntryExists: <T>(value: T[]) => T;
|
|
|
450
450
|
*/
|
|
451
451
|
export declare function mapNullFieldsToUndefined<T extends object>(obj: T): { [K in keyof T]: T[K] extends null ? undefined : Exclude<T[K], null>; };
|
|
452
452
|
//#endregion
|
|
453
|
-
//#region lib/scalars/address.d.ts
|
|
454
|
-
/**
|
|
455
|
-
* The shape of a postal address, modeled after the OIDC `address` claim
|
|
456
|
-
* (https://openid.net/specs/openid-connect-core-1_0.html#AddressClaim) and schema.org's
|
|
457
|
-
* `PostalAddress`.
|
|
458
|
-
*/
|
|
459
|
-
type AddressShape = {
|
|
460
|
-
/** The street address, which may be multiple lines separated by newlines. */
|
|
461
|
-
streetAddress?: string | null;
|
|
462
|
-
/** City or town. */
|
|
463
|
-
locality?: string | null;
|
|
464
|
-
/** State, province, prefecture or region. */
|
|
465
|
-
region?: string | null;
|
|
466
|
-
/** Postal or zip code. */
|
|
467
|
-
postalCode?: string | null;
|
|
468
|
-
/** ISO 3166-1 alpha-2 country code. */
|
|
469
|
-
countryCode?: string | null;
|
|
470
|
-
};
|
|
471
|
-
/**
|
|
472
|
-
* AddressInput's shape differs from AddressShape in that `countryCode` and `streetAddress` are
|
|
473
|
-
* required. `countryCode`: without a country there is nothing for the validator to check
|
|
474
|
-
* requiredness/format/region against, so a country-less "address" can't be verified as valid
|
|
475
|
-
* for anywhere. `streetAddress`: checked against every one of the 252 countries in
|
|
476
|
-
* libaddressinput's dataset — it is the one field required in literally all of them (unlike
|
|
477
|
-
* e.g. city, which 13 countries including Japan and Singapore don't require, or state/zip,
|
|
478
|
-
* required in barely a sixth to a third of countries) — so it's safe to require unconditionally
|
|
479
|
-
* rather than only per-country. The remaining fields stay optional since their requiredness
|
|
480
|
-
* genuinely varies by country; that's enforced dynamically by `addressValidationSchema` instead
|
|
481
|
-
* of statically here.
|
|
482
|
-
*/
|
|
483
|
-
type AddressInputShape = Omit<AddressShape, "countryCode" | "streetAddress"> & {
|
|
484
|
-
countryCode: string;
|
|
485
|
-
streetAddress: string;
|
|
486
|
-
};
|
|
487
|
-
//#endregion
|
|
488
453
|
//#region lib/args/whereArgsImplementer.d.ts
|
|
489
454
|
type NumberWhereInputArgument = {
|
|
490
455
|
eq?: number;
|
|
@@ -5253,6 +5218,148 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
5253
5218
|
buildSchema: () => GraphQLSchema;
|
|
5254
5219
|
};
|
|
5255
5220
|
//#endregion
|
|
5221
|
+
//#region lib/scalars/address.d.ts
|
|
5222
|
+
/**
|
|
5223
|
+
* The shape of a postal address, modeled after the OIDC `address` claim
|
|
5224
|
+
* (https://openid.net/specs/openid-connect-core-1_0.html#AddressClaim) and schema.org's
|
|
5225
|
+
* `PostalAddress`.
|
|
5226
|
+
*/
|
|
5227
|
+
type AddressShape = {
|
|
5228
|
+
/** The street address, which may be multiple lines separated by newlines. */
|
|
5229
|
+
streetAddress?: string | null;
|
|
5230
|
+
/** City or town. */
|
|
5231
|
+
locality?: string | null;
|
|
5232
|
+
/** State, province, prefecture or region. */
|
|
5233
|
+
region?: string | null;
|
|
5234
|
+
/** Postal or zip code. */
|
|
5235
|
+
postalCode?: string | null;
|
|
5236
|
+
/** ISO 3166-1 alpha-2 country code. */
|
|
5237
|
+
countryCode?: string | null;
|
|
5238
|
+
};
|
|
5239
|
+
/**
|
|
5240
|
+
* AddressInput's shape differs from AddressShape in that `countryCode` and `streetAddress` are
|
|
5241
|
+
* required. `countryCode`: without a country there is nothing for the validator to check
|
|
5242
|
+
* requiredness/format/region against, so a country-less "address" can't be verified as valid
|
|
5243
|
+
* for anywhere. `streetAddress`: checked against every one of the 252 countries in
|
|
5244
|
+
* libaddressinput's dataset — it is the one field required in literally all of them (unlike
|
|
5245
|
+
* e.g. city, which 13 countries including Japan and Singapore don't require, or state/zip,
|
|
5246
|
+
* required in barely a sixth to a third of countries) — so it's safe to require unconditionally
|
|
5247
|
+
* rather than only per-country. The remaining fields stay optional since their requiredness
|
|
5248
|
+
* genuinely varies by country; that's enforced dynamically by `addressValidationSchema` instead
|
|
5249
|
+
* of statically here.
|
|
5250
|
+
*/
|
|
5251
|
+
type AddressInputShape = Omit<AddressShape, "countryCode" | "streetAddress"> & {
|
|
5252
|
+
countryCode: string;
|
|
5253
|
+
streetAddress: string;
|
|
5254
|
+
};
|
|
5255
|
+
//#endregion
|
|
5256
|
+
//#region lib/scalars/addressData.d.ts
|
|
5257
|
+
type RegionAddressRules = {
|
|
5258
|
+
/** Regex the postal code must start with. */
|
|
5259
|
+
zip?: string;
|
|
5260
|
+
/** Example postal code within the region. */
|
|
5261
|
+
zipex?: string;
|
|
5262
|
+
/** Other names the region is known by, e.g. "California" for CA. */
|
|
5263
|
+
names?: string[];
|
|
5264
|
+
};
|
|
5265
|
+
type CountryAddressRules = {
|
|
5266
|
+
/** One-letter codes of the required fields, see the libaddressinput metadata docs. */
|
|
5267
|
+
require: string;
|
|
5268
|
+
/** Regex the whole postal code must match. */
|
|
5269
|
+
zip?: string;
|
|
5270
|
+
/** Example postal code. */
|
|
5271
|
+
zipex?: string;
|
|
5272
|
+
/** Regions by their upper-cased code. */
|
|
5273
|
+
regions?: Record<string, RegionAddressRules>;
|
|
5274
|
+
};
|
|
5275
|
+
/*! Address data derived from Google's Address Data Service (https://github.com/google/libaddressinput),
|
|
5276
|
+
* licensed under CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/).
|
|
5277
|
+
* Changes: reduced to required fields, postal code patterns and examples, and regions with
|
|
5278
|
+
* their names, with region codes upper-cased and ISO 3166-2 ids used where available. */
|
|
5279
|
+
export declare const addressData: Record<string, CountryAddressRules>;
|
|
5280
|
+
//#endregion
|
|
5281
|
+
//#region lib/scalars/addressValidation.d.ts
|
|
5282
|
+
type AddressIssue = {
|
|
5283
|
+
path: keyof AddressShape;
|
|
5284
|
+
message: string;
|
|
5285
|
+
};
|
|
5286
|
+
type NormalizedAddress = {
|
|
5287
|
+
streetAddress: string | null;
|
|
5288
|
+
locality: string | null;
|
|
5289
|
+
region: string | null;
|
|
5290
|
+
postalCode: string | null;
|
|
5291
|
+
countryCode: string;
|
|
5292
|
+
};
|
|
5293
|
+
/**
|
|
5294
|
+
* One rule an address is checked against, e.g. `checkPostalCode`. It only runs for countries
|
|
5295
|
+
* that have rules, and returns an empty array when the address passes.
|
|
5296
|
+
*/
|
|
5297
|
+
type AddressCheck = (args: {
|
|
5298
|
+
address: NormalizedAddress;
|
|
5299
|
+
rules: CountryAddressRules;
|
|
5300
|
+
}) => AddressIssue[];
|
|
5301
|
+
/** Flags fields the country requires but the address leaves empty. */
|
|
5302
|
+
export declare const checkRequiredFields: AddressCheck;
|
|
5303
|
+
/**
|
|
5304
|
+
* Flags a region that isn't in the country's region list. Countries without a list accept any
|
|
5305
|
+
* region. Expects the region already resolved by `normalizeAddress`.
|
|
5306
|
+
*/
|
|
5307
|
+
export declare const checkRegion: AddressCheck;
|
|
5308
|
+
/**
|
|
5309
|
+
* Flags a postal code that doesn't match the country's format, or doesn't belong to the given
|
|
5310
|
+
* region (e.g. a Washington ZIP code for California). An empty postal code passes, since
|
|
5311
|
+
* `checkRequiredFields` covers that.
|
|
5312
|
+
*/
|
|
5313
|
+
export declare const checkPostalCode: AddressCheck;
|
|
5314
|
+
/** The checks `validateAddress` runs, in order. */
|
|
5315
|
+
export declare const addressChecks: AddressCheck[];
|
|
5316
|
+
/**
|
|
5317
|
+
* Resolves a region code or any of its names, in any case, to the region code, e.g. "california"
|
|
5318
|
+
* to "CA" for the US. Returns undefined for unknown regions and countries without a region list.
|
|
5319
|
+
*/
|
|
5320
|
+
export declare function findRegionCode({ countryCode, region }: {
|
|
5321
|
+
countryCode: string;
|
|
5322
|
+
region: string;
|
|
5323
|
+
}): string | undefined;
|
|
5324
|
+
/**
|
|
5325
|
+
* Fixes the unambiguous, purely-cosmetic issues (stray surrounding whitespace, wrong case)
|
|
5326
|
+
* instead of rejecting an address over them. Run it before `validateAddress`, which expects
|
|
5327
|
+
* its output.
|
|
5328
|
+
*
|
|
5329
|
+
* `countryCode` and `postalCode` are uppercased since their canonical forms always are (ISO
|
|
5330
|
+
* 3166-1 codes, and postal codes in every country that mixes letters and digits, e.g. GB/CA/NL).
|
|
5331
|
+
* A region that matches a known region code or name, like "california" in the US, is replaced
|
|
5332
|
+
* by its code. Any other region and the locality are only trimmed, since they're free text.
|
|
5333
|
+
*/
|
|
5334
|
+
export declare function normalizeAddress(address: AddressShape): NormalizedAddress;
|
|
5335
|
+
/**
|
|
5336
|
+
* Checks a normalized address against its country's rules and returns every issue found, or an
|
|
5337
|
+
* empty array for a valid address.
|
|
5338
|
+
*
|
|
5339
|
+
* @example
|
|
5340
|
+
* ```ts
|
|
5341
|
+
* const issues = validateAddress(normalizeAddress(input));
|
|
5342
|
+
* ```
|
|
5343
|
+
*/
|
|
5344
|
+
export declare function validateAddress(address: NormalizedAddress): AddressIssue[];
|
|
5345
|
+
/**
|
|
5346
|
+
* The schema `AddressInput` validates with. It normalizes the address, so parsing returns the
|
|
5347
|
+
* corrected value, and reports every issue on its field.
|
|
5348
|
+
*/
|
|
5349
|
+
export declare const addressValidationSchema: z.ZodPipe<z.ZodObject<{
|
|
5350
|
+
streetAddress: z.ZodString;
|
|
5351
|
+
locality: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5352
|
+
region: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5353
|
+
postalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5354
|
+
countryCode: z.ZodString;
|
|
5355
|
+
}, z.core.$strip>, z.ZodTransform<NormalizedAddress, {
|
|
5356
|
+
streetAddress: string;
|
|
5357
|
+
locality?: string | null | undefined;
|
|
5358
|
+
region?: string | null | undefined;
|
|
5359
|
+
postalCode?: string | null | undefined;
|
|
5360
|
+
countryCode: string;
|
|
5361
|
+
}>>;
|
|
5362
|
+
//#endregion
|
|
5256
5363
|
//#region lib/scalars/emailAddress.d.ts
|
|
5257
5364
|
/**
|
|
5258
5365
|
* Validates an email address using graphql-scalars' own format check, then lowercases it, exactly
|
|
@@ -5298,4 +5405,5 @@ export declare class RumbleError extends Error {
|
|
|
5298
5405
|
*/
|
|
5299
5406
|
export declare class RumbleErrorSafe extends GraphQLError {}
|
|
5300
5407
|
//#endregion
|
|
5408
|
+
export type { AddressCheck, AddressInputShape, AddressIssue, AddressShape, CountryAddressRules, NormalizedAddress, RegionAddressRules };
|
|
5301
5409
|
//# sourceMappingURL=index.d.mts.map
|