@8ms/helpers 3.2.10 → 3.2.11

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 (47) hide show
  1. package/dist/aws/s3/server/AwsS3.cjs +1 -1
  2. package/dist/aws/s3/server/AwsS3.mjs +1 -1
  3. package/dist/googleCloud/bigquery/_shared/field/bqFloat.cjs +2 -2
  4. package/dist/googleCloud/bigquery/_shared/field/bqFloat.d.cts +1 -2
  5. package/dist/googleCloud/bigquery/_shared/field/bqFloat.d.mts +1 -2
  6. package/dist/googleCloud/bigquery/_shared/field/bqFloat.mjs +2 -2
  7. package/dist/googleCloud/bigquery/_shared/field/{bqNullableString.cjs → bqStringNullable.cjs} +3 -3
  8. package/dist/googleCloud/bigquery/_shared/field/{bqNullableString.d.cts → bqStringNullable.d.cts} +2 -2
  9. package/dist/googleCloud/bigquery/_shared/field/{bqNullableString.d.mts → bqStringNullable.d.mts} +2 -2
  10. package/dist/googleCloud/bigquery/_shared/field/{bqNullableString.mjs → bqStringNullable.mjs} +3 -3
  11. package/dist/googleCloud/bigquery/_shared/index.cjs +1 -1
  12. package/dist/googleCloud/bigquery/_shared/index.d.cts +2 -2
  13. package/dist/googleCloud/bigquery/_shared/index.d.mts +2 -2
  14. package/dist/googleCloud/bigquery/_shared/index.mjs +2 -2
  15. package/dist/googleCloud/bigquery/_shared/lookup/country.cjs +3 -3
  16. package/dist/googleCloud/bigquery/_shared/lookup/country.mjs +3 -3
  17. package/dist/googleCloud/bigquery/_shared/lookup/language.cjs +3 -3
  18. package/dist/googleCloud/bigquery/_shared/lookup/language.mjs +3 -3
  19. package/dist/googleCloud/bigquery/_shared/types.d.cts +5 -3
  20. package/dist/googleCloud/bigquery/_shared/types.d.mts +5 -3
  21. package/dist/googleCloud/bigquery/_shared/zodToBQDefinition.cjs +3 -2
  22. package/dist/googleCloud/bigquery/_shared/zodToBQDefinition.d.cts +1 -1
  23. package/dist/googleCloud/bigquery/_shared/zodToBQDefinition.d.mts +1 -1
  24. package/dist/googleCloud/bigquery/_shared/zodToBQDefinition.mjs +3 -2
  25. package/dist/googleCloud/bigquery/client/index.cjs +1 -1
  26. package/dist/googleCloud/bigquery/client/index.d.cts +2 -2
  27. package/dist/googleCloud/bigquery/client/index.d.mts +2 -2
  28. package/dist/googleCloud/bigquery/client/index.mjs +2 -2
  29. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.cjs +14 -4
  30. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.cts +8 -3
  31. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.d.mts +8 -3
  32. package/dist/googleCloud/bigquery/server/GoogleCloudBigquery.mjs +14 -4
  33. package/dist/googleCloud/bigquery/server/index.cjs +1 -1
  34. package/dist/googleCloud/bigquery/server/index.d.cts +2 -2
  35. package/dist/googleCloud/bigquery/server/index.d.mts +2 -2
  36. package/dist/googleCloud/bigquery/server/index.mjs +2 -2
  37. package/dist/lodash/_shared/index.cjs +4 -4
  38. package/dist/lodash/_shared/index.mjs +4 -4
  39. package/dist/lodash/client/index.cjs +4 -4
  40. package/dist/lodash/client/index.mjs +4 -4
  41. package/dist/lodash/server/index.cjs +4 -4
  42. package/dist/lodash/server/index.mjs +4 -4
  43. package/dist/url/server/writeUrlContents.cjs +3 -14
  44. package/dist/url/server/writeUrlContents.mjs +3 -14
  45. package/dist/xlsx/_shared/createXlsx.cjs +1 -1
  46. package/dist/xlsx/_shared/createXlsx.mjs +1 -1
  47. package/package.json +26 -26
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
3
3
  const require__class__shared_BaseNamespace = require("../../../_class/_shared/BaseNamespace.cjs");
4
+ const require_aws_server_isResponse200 = require("../../server/isResponse200.cjs");
4
5
  const require_date__shared_calculation = require("../../../date/_shared/calculation.cjs");
5
6
  const require_date__shared_format = require("../../../date/_shared/format.cjs");
6
- const require_aws_server_isResponse200 = require("../../server/isResponse200.cjs");
7
7
  const require_date__shared_date = require("../../../date/_shared/date.cjs");
8
8
  require("../../../date/_shared/index.cjs");
9
9
  const require_stream_server_json_read = require("../../../stream/server/json/read.cjs");
@@ -1,7 +1,7 @@
1
1
  import { BaseNamespace } from "../../../_class/_shared/BaseNamespace.mjs";
2
+ import { isResponse200 } from "../../server/isResponse200.mjs";
2
3
  import { getToday } from "../../../date/_shared/calculation.mjs";
3
4
  import { getYmdHisString } from "../../../date/_shared/format.mjs";
4
- import { isResponse200 } from "../../server/isResponse200.mjs";
5
5
  import { defaultDateTime } from "../../../date/_shared/date.mjs";
6
6
  import "../../../date/_shared/index.mjs";
7
7
  import { readJsonGzipStream, readJsonStream } from "../../../stream/server/json/read.mjs";
@@ -3,6 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  /**
4
4
  * FLOAT64 → plain JS number
5
5
  */
6
- const BQFloat = require("zod").z.number();
6
+ const zBQFloat = require("zod").z.number().describe("bq:float");
7
7
  //#endregion
8
- exports.BQFloat = BQFloat;
8
+ exports.zBQFloat = zBQFloat;
@@ -3,6 +3,5 @@ import { z } from "zod";
3
3
  /**
4
4
  * FLOAT64 → plain JS number
5
5
  */
6
- export declare const BQFloat: z.ZodNumber;
7
- export type BQFloat = z.infer<typeof BQFloat>;
6
+ export declare const zBQFloat: z.ZodNumber;
8
7
  //#endregion
@@ -3,6 +3,5 @@ import { z } from "zod";
3
3
  /**
4
4
  * FLOAT64 → plain JS number
5
5
  */
6
- export declare const BQFloat: z.ZodNumber;
7
- export type BQFloat = z.infer<typeof BQFloat>;
6
+ export declare const zBQFloat: z.ZodNumber;
8
7
  //#endregion
@@ -3,6 +3,6 @@ import { z } from "zod";
3
3
  /**
4
4
  * FLOAT64 → plain JS number
5
5
  */
6
- const BQFloat = z.number();
6
+ const zBQFloat = z.number().describe("bq:float");
7
7
  //#endregion
8
- export { BQFloat };
8
+ export { zBQFloat };
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let zod = require("zod");
3
- //#region src/googleCloud/bigquery/_shared/field/bqNullableString.ts
3
+ //#region src/googleCloud/bigquery/_shared/field/bqStringNullable.ts
4
4
  /**
5
5
  * BigQuery's Node client returns small INT64 values as a native `number` and only falls back to
6
6
  * `string` once precision would be lost - so an INT64/NUMERIC column stored as an id (e.g.
7
7
  * google_ads_id) can't be trusted to always arrive as a string. Coerce defensively instead.
8
8
  */
9
- const BQNullableStringCoerce = zod.z.preprocess((value) => null === value || void 0 === value ? null : String(value), zod.z.string().nullable());
9
+ const BQStringNullable = zod.z.preprocess((value) => null === value || void 0 === value ? null : String(value), zod.z.string().nullable());
10
10
  //#endregion
11
- exports.BQNullableStringCoerce = BQNullableStringCoerce;
11
+ exports.BQStringNullable = BQStringNullable;
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
- //#region src/googleCloud/bigquery/_shared/field/bqNullableString.d.ts
2
+ //#region src/googleCloud/bigquery/_shared/field/bqStringNullable.d.ts
3
3
  /**
4
4
  * BigQuery's Node client returns small INT64 values as a native `number` and only falls back to
5
5
  * `string` once precision would be lost - so an INT64/NUMERIC column stored as an id (e.g.
6
6
  * google_ads_id) can't be trusted to always arrive as a string. Coerce defensively instead.
7
7
  */
8
- export declare const BQNullableStringCoerce: z.ZodPreprocess<z.ZodNullable<z.ZodString>, unknown>;
8
+ export declare const BQStringNullable: z.ZodPreprocess<z.ZodNullable<z.ZodString>, unknown>;
9
9
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
- //#region src/googleCloud/bigquery/_shared/field/bqNullableString.d.ts
2
+ //#region src/googleCloud/bigquery/_shared/field/bqStringNullable.d.ts
3
3
  /**
4
4
  * BigQuery's Node client returns small INT64 values as a native `number` and only falls back to
5
5
  * `string` once precision would be lost - so an INT64/NUMERIC column stored as an id (e.g.
6
6
  * google_ads_id) can't be trusted to always arrive as a string. Coerce defensively instead.
7
7
  */
8
- export declare const BQNullableStringCoerce: z.ZodPreprocess<z.ZodNullable<z.ZodString>, unknown>;
8
+ export declare const BQStringNullable: z.ZodPreprocess<z.ZodNullable<z.ZodString>, unknown>;
9
9
  //#endregion
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
- //#region src/googleCloud/bigquery/_shared/field/bqNullableString.ts
2
+ //#region src/googleCloud/bigquery/_shared/field/bqStringNullable.ts
3
3
  /**
4
4
  * BigQuery's Node client returns small INT64 values as a native `number` and only falls back to
5
5
  * `string` once precision would be lost - so an INT64/NUMERIC column stored as an id (e.g.
6
6
  * google_ads_id) can't be trusted to always arrive as a string. Coerce defensively instead.
7
7
  */
8
- const BQNullableStringCoerce = z.preprocess((value) => null === value || void 0 === value ? null : String(value), z.string().nullable());
8
+ const BQStringNullable = z.preprocess((value) => null === value || void 0 === value ? null : String(value), z.string().nullable());
9
9
  //#endregion
10
- export { BQNullableStringCoerce };
10
+ export { BQStringNullable };
@@ -26,7 +26,6 @@ exports.BQFieldMode = require_googleCloud_bigquery__shared_field_bqFieldMode.BQF
26
26
  exports.BQFieldModeSchema = require_googleCloud_bigquery__shared_field_bqFieldMode.BQFieldModeSchema;
27
27
  exports.BQFieldType = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldType;
28
28
  exports.BQFieldTypeSchema = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldTypeSchema;
29
- exports.BQFloat = require_googleCloud_bigquery__shared_field_bqFloat.BQFloat;
30
29
  exports.BQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.BQInt64;
31
30
  exports.BQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.BQNumeric;
32
31
  exports.BQString = require_googleCloud_bigquery__shared_field_bqString.BQString;
@@ -42,6 +41,7 @@ exports.googleCloudBQRow = require_googleCloud_bigquery__shared_lookup_googleClo
42
41
  exports.languageBQRow = require_googleCloud_bigquery__shared_lookup_language.languageBQRow;
43
42
  exports.partitionType = require_googleCloud_bigquery__shared_partitionType.partitionType;
44
43
  exports.zBQBytes = require_googleCloud_bigquery__shared_field_bqBytes.zBQBytes;
44
+ exports.zBQFloat = require_googleCloud_bigquery__shared_field_bqFloat.zBQFloat;
45
45
  exports.zBQInt = require_googleCloud_bigquery__shared_field_bqInt.zBQInt;
46
46
  exports.zBQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.zBQInt64;
47
47
  exports.zBQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.zBQNumeric;
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "./field/bqDate.c
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "./field/bqDateTime.cjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "./field/bqFieldMode.cjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "./field/bqFieldType.cjs";
7
- import { BQFloat } from "./field/bqFloat.cjs";
7
+ import { zBQFloat } from "./field/bqFloat.cjs";
8
8
  import { zBQInt } from "./field/bqInt.cjs";
9
9
  import { BQInt64, zBQInt64 } from "./field/bqInt64.cjs";
10
10
  import { BQNumeric, zBQNumeric } from "./field/bqNumeric.cjs";
@@ -18,4 +18,4 @@ import { LanguageBQRow, languageBQRow } from "./lookup/language.cjs";
18
18
  import { PartitionType, partitionType } from "./partitionType.cjs";
19
19
  import { BQField, zodToBQSchema } from "./zodToBQDefinition.cjs";
20
20
  import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "./types.cjs";
21
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
21
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "./field/bqDate.m
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "./field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "./field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "./field/bqFieldType.mjs";
7
- import { BQFloat } from "./field/bqFloat.mjs";
7
+ import { zBQFloat } from "./field/bqFloat.mjs";
8
8
  import { zBQInt } from "./field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "./field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "./field/bqNumeric.mjs";
@@ -18,4 +18,4 @@ import { LanguageBQRow, languageBQRow } from "./lookup/language.mjs";
18
18
  import { PartitionType, partitionType } from "./partitionType.mjs";
19
19
  import { BQField, zodToBQSchema } from "./zodToBQDefinition.mjs";
20
20
  import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "./types.mjs";
21
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
21
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "./field/bqDate.m
4
4
  import { BQDateTime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "./field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "./field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "./field/bqFieldType.mjs";
7
- import { BQFloat } from "./field/bqFloat.mjs";
7
+ import { zBQFloat } from "./field/bqFloat.mjs";
8
8
  import { zBQInt } from "./field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "./field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "./field/bqNumeric.mjs";
@@ -17,4 +17,4 @@ import { googleCloudBQRow } from "./lookup/googleCloud.mjs";
17
17
  import { languageBQRow } from "./lookup/language.mjs";
18
18
  import { partitionType } from "./partitionType.mjs";
19
19
  import { zodToBQSchema } from "./zodToBQDefinition.mjs";
20
- export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
20
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_googleCloud_bigquery__shared_field_bqDateTime = require("../field/bqDateTime.cjs");
3
- const require_googleCloud_bigquery__shared_field_bqNullableString = require("../field/bqNullableString.cjs");
3
+ const require_googleCloud_bigquery__shared_field_bqStringNullable = require("../field/bqStringNullable.cjs");
4
4
  let zod = require("zod");
5
5
  //#region src/googleCloud/bigquery/_shared/lookup/country.ts
6
6
  /**
@@ -12,8 +12,8 @@ const countryBQRow = zod.z.object({
12
12
  country: zod.z.string(),
13
13
  alpha2: zod.z.string().nullable(),
14
14
  alpha3: zod.z.string().nullable(),
15
- google_ads_id: require_googleCloud_bigquery__shared_field_bqNullableString.BQNullableStringCoerce,
16
- meta_id: require_googleCloud_bigquery__shared_field_bqNullableString.BQNullableStringCoerce,
15
+ google_ads_id: require_googleCloud_bigquery__shared_field_bqStringNullable.BQStringNullable,
16
+ meta_id: require_googleCloud_bigquery__shared_field_bqStringNullable.BQStringNullable,
17
17
  inserted_at: require_googleCloud_bigquery__shared_field_bqDateTime.BQDateTime.transform(require_googleCloud_bigquery__shared_field_bqDateTime.decodeBQDateTime)
18
18
  });
19
19
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { BQDateTime, decodeBQDateTime } from "../field/bqDateTime.mjs";
2
- import { BQNullableStringCoerce } from "../field/bqNullableString.mjs";
2
+ import { BQStringNullable } from "../field/bqStringNullable.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/googleCloud/bigquery/_shared/lookup/country.ts
5
5
  /**
@@ -11,8 +11,8 @@ const countryBQRow = z.object({
11
11
  country: z.string(),
12
12
  alpha2: z.string().nullable(),
13
13
  alpha3: z.string().nullable(),
14
- google_ads_id: BQNullableStringCoerce,
15
- meta_id: BQNullableStringCoerce,
14
+ google_ads_id: BQStringNullable,
15
+ meta_id: BQStringNullable,
16
16
  inserted_at: BQDateTime.transform(decodeBQDateTime)
17
17
  });
18
18
  //#endregion
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_googleCloud_bigquery__shared_field_bqDateTime = require("../field/bqDateTime.cjs");
3
- const require_googleCloud_bigquery__shared_field_bqNullableString = require("../field/bqNullableString.cjs");
3
+ const require_googleCloud_bigquery__shared_field_bqStringNullable = require("../field/bqStringNullable.cjs");
4
4
  let zod = require("zod");
5
5
  //#region src/googleCloud/bigquery/_shared/lookup/language.ts
6
6
  /**
@@ -11,8 +11,8 @@ let zod = require("zod");
11
11
  const languageBQRow = zod.z.object({
12
12
  language: zod.z.string(),
13
13
  iso2: zod.z.string().nullable(),
14
- google_ads_id: require_googleCloud_bigquery__shared_field_bqNullableString.BQNullableStringCoerce,
15
- meta_id: require_googleCloud_bigquery__shared_field_bqNullableString.BQNullableStringCoerce,
14
+ google_ads_id: require_googleCloud_bigquery__shared_field_bqStringNullable.BQStringNullable,
15
+ meta_id: require_googleCloud_bigquery__shared_field_bqStringNullable.BQStringNullable,
16
16
  inserted_at: require_googleCloud_bigquery__shared_field_bqDateTime.BQDateTime.transform(require_googleCloud_bigquery__shared_field_bqDateTime.decodeBQDateTime)
17
17
  });
18
18
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { BQDateTime, decodeBQDateTime } from "../field/bqDateTime.mjs";
2
- import { BQNullableStringCoerce } from "../field/bqNullableString.mjs";
2
+ import { BQStringNullable } from "../field/bqStringNullable.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/googleCloud/bigquery/_shared/lookup/language.ts
5
5
  /**
@@ -10,8 +10,8 @@ import { z } from "zod";
10
10
  const languageBQRow = z.object({
11
11
  language: z.string(),
12
12
  iso2: z.string().nullable(),
13
- google_ads_id: BQNullableStringCoerce,
14
- meta_id: BQNullableStringCoerce,
13
+ google_ads_id: BQStringNullable,
14
+ meta_id: BQStringNullable,
15
15
  inserted_at: BQDateTime.transform(decodeBQDateTime)
16
16
  });
17
17
  //#endregion
@@ -8,9 +8,9 @@ import { QueryOptions } from "@google-cloud/bigquery";
8
8
  /** The only load formats this library can actually serialise/pass through for loadTable/loadStreamTable. */
9
9
  export type BigqueryLoadFormat = typeof fileType.CSV | typeof fileType.JSON_NEWLINE | typeof fileType.PARQUET;
10
10
  export type TableDefinition = {
11
- projectId?: string;
11
+ projectId: string;
12
12
  datasetId: string;
13
- tableId?: string;
13
+ tableId: string;
14
14
  options?: {
15
15
  location?: string;
16
16
  schema: BQField[];
@@ -48,12 +48,14 @@ export type LoadData<TData> = {
48
48
  table: TableDefinition & {
49
49
  tableId: string;
50
50
  };
51
+ autodetect?: boolean;
52
+ schema?: BQField[];
51
53
  };
52
54
  export type LoadTableProps = LoadData<any[]>;
53
55
  export type LoadStreamTableProps = LoadData<RowSource<any>>;
54
56
  export type MergeTableProps = Omit<LoadData<any[]>, "table"> & {
55
57
  table: LoadData<any[]>["table"] & {
56
- mergeKey: string;
58
+ mergeColumns: string[];
57
59
  updateColumns: string[];
58
60
  };
59
61
  };
@@ -8,9 +8,9 @@ import { QueryOptions } from "@google-cloud/bigquery";
8
8
  /** The only load formats this library can actually serialise/pass through for loadTable/loadStreamTable. */
9
9
  export type BigqueryLoadFormat = typeof fileType.CSV | typeof fileType.JSON_NEWLINE | typeof fileType.PARQUET;
10
10
  export type TableDefinition = {
11
- projectId?: string;
11
+ projectId: string;
12
12
  datasetId: string;
13
- tableId?: string;
13
+ tableId: string;
14
14
  options?: {
15
15
  location?: string;
16
16
  schema: BQField[];
@@ -48,12 +48,14 @@ export type LoadData<TData> = {
48
48
  table: TableDefinition & {
49
49
  tableId: string;
50
50
  };
51
+ autodetect?: boolean;
52
+ schema?: BQField[];
51
53
  };
52
54
  export type LoadTableProps = LoadData<any[]>;
53
55
  export type LoadStreamTableProps = LoadData<RowSource<any>>;
54
56
  export type MergeTableProps = Omit<LoadData<any[]>, "table"> & {
55
57
  table: LoadData<any[]>["table"] & {
56
- mergeKey: string;
58
+ mergeColumns: string[];
57
59
  updateColumns: string[];
58
60
  };
59
61
  };
@@ -5,14 +5,15 @@ const getBqType = (schema) => {
5
5
  if ("bq:date" === schema.description) return "DATE";
6
6
  if ("bq:datetime" === schema.description) return "DATETIME";
7
7
  if ("bq:int" === schema.description) return "INTEGER";
8
+ if ("bq:float" === schema.description) return "FLOAT";
8
9
  if ("bq:numeric" === schema.description) return "NUMERIC";
9
10
  if ("bq:int64" === schema.description) return "INTEGER";
10
11
  if ("bq:time" === schema.description) return "TIME";
11
12
  if ("bq:bytes" === schema.description) return "BYTES";
12
13
  if (schema instanceof zod.z.ZodString || schema instanceof zod.z.ZodEnum) return "STRING";
13
- if (schema instanceof zod.z.ZodNumber) return "FLOAT";
14
14
  if (schema instanceof zod.z.ZodBoolean) return "BOOLEAN";
15
15
  if (schema instanceof zod.z.ZodDate) return "TIMESTAMP";
16
+ if (schema instanceof zod.z.ZodNumber) throw new Error("A BigQuery number field must be tagged zBQInt or zBQFloat - plain z.number() is ambiguous between INTEGER and FLOAT.");
16
17
  throw new Error(`Cannot infer a BigQuery type for zod schema "${schema.constructor.name}".`);
17
18
  };
18
19
  /**
@@ -37,7 +38,7 @@ const buildBQField = (name, fieldSchema) => {
37
38
  name,
38
39
  type: "RECORD",
39
40
  mode,
40
- fields: zodToBQSchema(inner)
41
+ subFields: zodToBQSchema(inner)
41
42
  };
42
43
  return {
43
44
  name,
@@ -7,7 +7,7 @@ export type BQField = {
7
7
  type: BQFieldType;
8
8
  mode: BQFieldMode;
9
9
  defaultValueExpression?: string;
10
- fields?: BQField[];
10
+ subFields?: BQField[];
11
11
  };
12
12
  /**
13
13
  * Derives a BigQuery table schema directly from a zod object's shape - the column name and type
@@ -7,7 +7,7 @@ export type BQField = {
7
7
  type: BQFieldType;
8
8
  mode: BQFieldMode;
9
9
  defaultValueExpression?: string;
10
- fields?: BQField[];
10
+ subFields?: BQField[];
11
11
  };
12
12
  /**
13
13
  * Derives a BigQuery table schema directly from a zod object's shape - the column name and type
@@ -4,14 +4,15 @@ const getBqType = (schema) => {
4
4
  if ("bq:date" === schema.description) return "DATE";
5
5
  if ("bq:datetime" === schema.description) return "DATETIME";
6
6
  if ("bq:int" === schema.description) return "INTEGER";
7
+ if ("bq:float" === schema.description) return "FLOAT";
7
8
  if ("bq:numeric" === schema.description) return "NUMERIC";
8
9
  if ("bq:int64" === schema.description) return "INTEGER";
9
10
  if ("bq:time" === schema.description) return "TIME";
10
11
  if ("bq:bytes" === schema.description) return "BYTES";
11
12
  if (schema instanceof z.ZodString || schema instanceof z.ZodEnum) return "STRING";
12
- if (schema instanceof z.ZodNumber) return "FLOAT";
13
13
  if (schema instanceof z.ZodBoolean) return "BOOLEAN";
14
14
  if (schema instanceof z.ZodDate) return "TIMESTAMP";
15
+ if (schema instanceof z.ZodNumber) throw new Error("A BigQuery number field must be tagged zBQInt or zBQFloat - plain z.number() is ambiguous between INTEGER and FLOAT.");
15
16
  throw new Error(`Cannot infer a BigQuery type for zod schema "${schema.constructor.name}".`);
16
17
  };
17
18
  /**
@@ -36,7 +37,7 @@ const buildBQField = (name, fieldSchema) => {
36
37
  name,
37
38
  type: "RECORD",
38
39
  mode,
39
- fields: zodToBQSchema(inner)
40
+ subFields: zodToBQSchema(inner)
40
41
  };
41
42
  return {
42
43
  name,
@@ -27,7 +27,6 @@ exports.BQFieldMode = require_googleCloud_bigquery__shared_field_bqFieldMode.BQF
27
27
  exports.BQFieldModeSchema = require_googleCloud_bigquery__shared_field_bqFieldMode.BQFieldModeSchema;
28
28
  exports.BQFieldType = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldType;
29
29
  exports.BQFieldTypeSchema = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldTypeSchema;
30
- exports.BQFloat = require_googleCloud_bigquery__shared_field_bqFloat.BQFloat;
31
30
  exports.BQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.BQInt64;
32
31
  exports.BQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.BQNumeric;
33
32
  exports.BQString = require_googleCloud_bigquery__shared_field_bqString.BQString;
@@ -43,6 +42,7 @@ exports.googleCloudBQRow = require_googleCloud_bigquery__shared_lookup_googleClo
43
42
  exports.languageBQRow = require_googleCloud_bigquery__shared_lookup_language.languageBQRow;
44
43
  exports.partitionType = require_googleCloud_bigquery__shared_partitionType.partitionType;
45
44
  exports.zBQBytes = require_googleCloud_bigquery__shared_field_bqBytes.zBQBytes;
45
+ exports.zBQFloat = require_googleCloud_bigquery__shared_field_bqFloat.zBQFloat;
46
46
  exports.zBQInt = require_googleCloud_bigquery__shared_field_bqInt.zBQInt;
47
47
  exports.zBQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.zBQInt64;
48
48
  exports.zBQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.zBQNumeric;
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.cjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.cjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.cjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.cjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.cjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.cjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.cjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.cjs";
@@ -19,4 +19,4 @@ import { PartitionType, partitionType } from "../_shared/partitionType.cjs";
19
19
  import { BQField, zodToBQSchema } from "../_shared/zodToBQDefinition.cjs";
20
20
  import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "../_shared/types.cjs";
21
21
  import "../_shared/index.cjs";
22
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
22
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.mjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.mjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.mjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.mjs";
@@ -19,4 +19,4 @@ import { PartitionType, partitionType } from "../_shared/partitionType.mjs";
19
19
  import { BQField, zodToBQSchema } from "../_shared/zodToBQDefinition.mjs";
20
20
  import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "../_shared/types.mjs";
21
21
  import "../_shared/index.mjs";
22
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
22
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.mjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.mjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.mjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.mjs";
@@ -18,4 +18,4 @@ import { languageBQRow } from "../_shared/lookup/language.mjs";
18
18
  import { partitionType } from "../_shared/partitionType.mjs";
19
19
  import { zodToBQSchema } from "../_shared/zodToBQDefinition.mjs";
20
20
  import "../_shared/index.mjs";
21
- export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
21
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -98,7 +98,15 @@ var GoogleCloudBigquery = class extends require__class__shared_BaseNamespace.Bas
98
98
  * Make a request to the database and return the object per row.
99
99
  */
100
100
  query = async (props) => {
101
- return await this.client.query(this.buildQueryOptions(props));
101
+ const [rows] = await this.client.query(this.buildQueryOptions(props));
102
+ return rows;
103
+ };
104
+ /**
105
+ * Make a request to the database and return the first row, or null if there are none.
106
+ * Does not add a LIMIT - the full result set is still fetched, so include one in the query if it is large.
107
+ */
108
+ querySingle = async (props) => {
109
+ return (await this.query(props))[0] ?? null;
102
110
  };
103
111
  /**
104
112
  * Return the raw row stream for a query, without buffering the full result set in memory.
@@ -150,7 +158,8 @@ var GoogleCloudBigquery = class extends require__class__shared_BaseNamespace.Bas
150
158
  const finalRegion = props.table.options?.location ?? this.region;
151
159
  await this.createTable(props.table.datasetId, {}, props.table.tableId, props.table.options);
152
160
  await this.client.dataset(props.table.datasetId, { location: finalRegion }).table(props.table.tableId).load(props.googleCloudStorage.client.bucket(props.file.bucket).file(props.file.key), {
153
- autodetect: true,
161
+ autodetect: props.schema ? false : props.autodetect ?? true,
162
+ schema: props.schema ? { fields: props.schema } : void 0,
154
163
  sourceFormat: bigQuerySourceFormat[props.file.sourceFormat ?? require_file__shared_fileType.fileType.JSON_NEWLINE],
155
164
  schemaUpdateOptions: ["ALLOW_FIELD_ADDITION"],
156
165
  location: finalRegion
@@ -222,7 +231,7 @@ var GoogleCloudBigquery = class extends require__class__shared_BaseNamespace.Bas
222
231
  const stagingTableId = `${props.table.tableId}_staging_${require_date__shared_format.getYmdHisNumber()}`;
223
232
  const stagingTableRef = `\`${props.table.datasetId}.${stagingTableId}\``;
224
233
  try {
225
- const { mergeKey: _mergeKey, updateColumns: _updateColumns, ...tableDefinition } = props.table;
234
+ const { mergeColumns: _mergeColumns, updateColumns: _updateColumns, ...tableDefinition } = props.table;
226
235
  const stagingDefinition = {
227
236
  ...tableDefinition,
228
237
  tableId: stagingTableId,
@@ -238,12 +247,13 @@ var GoogleCloudBigquery = class extends require__class__shared_BaseNamespace.Bas
238
247
  table: stagingDefinition
239
248
  });
240
249
  const mainTableRef = `\`${props.table.datasetId}.${props.table.tableId}\``;
250
+ if (0 === props.table.mergeColumns.length) throw new Error("mergeTable requires at least one merge key.");
241
251
  const updateSet = props.table.updateColumns.map((column) => `${column} = S.${column}`).join(", ");
242
252
  const allColumns = props.table.options?.schema.map((field) => field.name) ?? [];
243
253
  const mergeQuery = `
244
254
  MERGE ${mainTableRef} AS T
245
255
  USING ${stagingTableRef} AS S
246
- ON T.${props.table.mergeKey} = S.${props.table.mergeKey}
256
+ ON ${props.table.mergeColumns.map((key) => `T.${key} = S.${key}`).join(" AND ")}
247
257
  WHEN MATCHED THEN
248
258
  UPDATE SET ${updateSet}
249
259
  WHEN NOT MATCHED THEN
@@ -1,5 +1,5 @@
1
1
  import { BaseNamespace } from "../../../_class/_shared/BaseNamespace.cjs";
2
- import { Dataset, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table } from "../_shared/types.cjs";
2
+ import { Dataset, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "../_shared/types.cjs";
3
3
  import "../_shared/index.cjs";
4
4
  import { ResourceStream } from "../../../node_modules/@google-cloud/paginator/build/src/resource-stream.cjs";
5
5
  import { BigQuery, DatasetResource } from "@google-cloud/bigquery";
@@ -32,7 +32,12 @@ export declare class GoogleCloudBigquery extends BaseNamespace {
32
32
  /**
33
33
  * Make a request to the database and return the object per row.
34
34
  */
35
- query: (props: QueryInput) => Promise<any>;
35
+ query: <TRow = any>(props: QueryInput) => Promise<TRow[]>;
36
+ /**
37
+ * Make a request to the database and return the first row, or null if there are none.
38
+ * Does not add a LIMIT - the full result set is still fetched, so include one in the query if it is large.
39
+ */
40
+ querySingle: <TRow = any>(props: QueryInput) => Promise<TRow | null>;
36
41
  /**
37
42
  * Return the raw row stream for a query, without buffering the full result set in memory.
38
43
  */
@@ -40,7 +45,7 @@ export declare class GoogleCloudBigquery extends BaseNamespace {
40
45
  /**
41
46
  * Create a Table if it doesn't already exist.
42
47
  */
43
- createTable: (datasetId: string, datasetOptions: object | undefined, tableId: string, options?: object) => Promise<void>;
48
+ createTable: (datasetId: string, datasetOptions: object | undefined, tableId: string, options?: TableDefinition["options"]) => Promise<void>;
44
49
  /**
45
50
  * Check to see whether a given BigQuery table exists.
46
51
  * https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
@@ -1,5 +1,5 @@
1
1
  import { BaseNamespace } from "../../../_class/_shared/BaseNamespace.mjs";
2
- import { Dataset, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table } from "../_shared/types.mjs";
2
+ import { Dataset, LoadStreamTableProps, LoadTableProps, MergeTableProps, QueryInput, Table, TableDefinition } from "../_shared/types.mjs";
3
3
  import "../_shared/index.mjs";
4
4
  import { ResourceStream } from "../../../node_modules/@google-cloud/paginator/build/src/resource-stream.mjs";
5
5
  import { BigQuery, DatasetResource } from "@google-cloud/bigquery";
@@ -32,7 +32,12 @@ export declare class GoogleCloudBigquery extends BaseNamespace {
32
32
  /**
33
33
  * Make a request to the database and return the object per row.
34
34
  */
35
- query: (props: QueryInput) => Promise<any>;
35
+ query: <TRow = any>(props: QueryInput) => Promise<TRow[]>;
36
+ /**
37
+ * Make a request to the database and return the first row, or null if there are none.
38
+ * Does not add a LIMIT - the full result set is still fetched, so include one in the query if it is large.
39
+ */
40
+ querySingle: <TRow = any>(props: QueryInput) => Promise<TRow | null>;
36
41
  /**
37
42
  * Return the raw row stream for a query, without buffering the full result set in memory.
38
43
  */
@@ -40,7 +45,7 @@ export declare class GoogleCloudBigquery extends BaseNamespace {
40
45
  /**
41
46
  * Create a Table if it doesn't already exist.
42
47
  */
43
- createTable: (datasetId: string, datasetOptions: object | undefined, tableId: string, options?: object) => Promise<void>;
48
+ createTable: (datasetId: string, datasetOptions: object | undefined, tableId: string, options?: TableDefinition["options"]) => Promise<void>;
44
49
  /**
45
50
  * Check to see whether a given BigQuery table exists.
46
51
  * https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
@@ -97,7 +97,15 @@ var GoogleCloudBigquery = class extends BaseNamespace {
97
97
  * Make a request to the database and return the object per row.
98
98
  */
99
99
  query = async (props) => {
100
- return await this.client.query(this.buildQueryOptions(props));
100
+ const [rows] = await this.client.query(this.buildQueryOptions(props));
101
+ return rows;
102
+ };
103
+ /**
104
+ * Make a request to the database and return the first row, or null if there are none.
105
+ * Does not add a LIMIT - the full result set is still fetched, so include one in the query if it is large.
106
+ */
107
+ querySingle = async (props) => {
108
+ return (await this.query(props))[0] ?? null;
101
109
  };
102
110
  /**
103
111
  * Return the raw row stream for a query, without buffering the full result set in memory.
@@ -149,7 +157,8 @@ var GoogleCloudBigquery = class extends BaseNamespace {
149
157
  const finalRegion = props.table.options?.location ?? this.region;
150
158
  await this.createTable(props.table.datasetId, {}, props.table.tableId, props.table.options);
151
159
  await this.client.dataset(props.table.datasetId, { location: finalRegion }).table(props.table.tableId).load(props.googleCloudStorage.client.bucket(props.file.bucket).file(props.file.key), {
152
- autodetect: true,
160
+ autodetect: props.schema ? false : props.autodetect ?? true,
161
+ schema: props.schema ? { fields: props.schema } : void 0,
153
162
  sourceFormat: bigQuerySourceFormat[props.file.sourceFormat ?? fileType.JSON_NEWLINE],
154
163
  schemaUpdateOptions: ["ALLOW_FIELD_ADDITION"],
155
164
  location: finalRegion
@@ -221,7 +230,7 @@ var GoogleCloudBigquery = class extends BaseNamespace {
221
230
  const stagingTableId = `${props.table.tableId}_staging_${getYmdHisNumber()}`;
222
231
  const stagingTableRef = `\`${props.table.datasetId}.${stagingTableId}\``;
223
232
  try {
224
- const { mergeKey: _mergeKey, updateColumns: _updateColumns, ...tableDefinition } = props.table;
233
+ const { mergeColumns: _mergeColumns, updateColumns: _updateColumns, ...tableDefinition } = props.table;
225
234
  const stagingDefinition = {
226
235
  ...tableDefinition,
227
236
  tableId: stagingTableId,
@@ -237,12 +246,13 @@ var GoogleCloudBigquery = class extends BaseNamespace {
237
246
  table: stagingDefinition
238
247
  });
239
248
  const mainTableRef = `\`${props.table.datasetId}.${props.table.tableId}\``;
249
+ if (0 === props.table.mergeColumns.length) throw new Error("mergeTable requires at least one merge key.");
240
250
  const updateSet = props.table.updateColumns.map((column) => `${column} = S.${column}`).join(", ");
241
251
  const allColumns = props.table.options?.schema.map((field) => field.name) ?? [];
242
252
  const mergeQuery = `
243
253
  MERGE ${mainTableRef} AS T
244
254
  USING ${stagingTableRef} AS S
245
- ON T.${props.table.mergeKey} = S.${props.table.mergeKey}
255
+ ON ${props.table.mergeColumns.map((key) => `T.${key} = S.${key}`).join(" AND ")}
246
256
  WHEN MATCHED THEN
247
257
  UPDATE SET ${updateSet}
248
258
  WHEN NOT MATCHED THEN
@@ -29,7 +29,6 @@ exports.BQFieldMode = require_googleCloud_bigquery__shared_field_bqFieldMode.BQF
29
29
  exports.BQFieldModeSchema = require_googleCloud_bigquery__shared_field_bqFieldMode.BQFieldModeSchema;
30
30
  exports.BQFieldType = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldType;
31
31
  exports.BQFieldTypeSchema = require_googleCloud_bigquery__shared_field_bqFieldType.BQFieldTypeSchema;
32
- exports.BQFloat = require_googleCloud_bigquery__shared_field_bqFloat.BQFloat;
33
32
  exports.BQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.BQInt64;
34
33
  exports.BQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.BQNumeric;
35
34
  exports.BQString = require_googleCloud_bigquery__shared_field_bqString.BQString;
@@ -47,6 +46,7 @@ exports.googleCloudBQRow = require_googleCloud_bigquery__shared_lookup_googleClo
47
46
  exports.languageBQRow = require_googleCloud_bigquery__shared_lookup_language.languageBQRow;
48
47
  exports.partitionType = require_googleCloud_bigquery__shared_partitionType.partitionType;
49
48
  exports.zBQBytes = require_googleCloud_bigquery__shared_field_bqBytes.zBQBytes;
49
+ exports.zBQFloat = require_googleCloud_bigquery__shared_field_bqFloat.zBQFloat;
50
50
  exports.zBQInt = require_googleCloud_bigquery__shared_field_bqInt.zBQInt;
51
51
  exports.zBQInt64 = require_googleCloud_bigquery__shared_field_bqInt64.zBQInt64;
52
52
  exports.zBQNumeric = require_googleCloud_bigquery__shared_field_bqNumeric.zBQNumeric;
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.cjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.cjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.cjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.cjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.cjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.cjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.cjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.cjs";
@@ -21,4 +21,4 @@ import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableP
21
21
  import "../_shared/index.cjs";
22
22
  import { GoogleCloudBigquery } from "./GoogleCloudBigquery.cjs";
23
23
  import { getHandlerPath } from "./getHandlerPath.cjs";
24
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, GoogleCloudBigquery, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
24
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, GoogleCloudBigquery, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, BQDatetime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.mjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.mjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.mjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.mjs";
@@ -21,4 +21,4 @@ import { BigqueryLoadFormat, Dataset, LoadData, LoadStreamTableProps, LoadTableP
21
21
  import "../_shared/index.mjs";
22
22
  import { GoogleCloudBigquery } from "./GoogleCloudBigquery.mjs";
23
23
  import { getHandlerPath } from "./getHandlerPath.mjs";
24
- export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, GoogleCloudBigquery, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
24
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQDatetime, BQField, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, BigqueryLoadFormat, CountryBQRow, Dataset, GoogleAdsAccountBQRow, GoogleCloudBQRow, GoogleCloudBigquery, LanguageBQRow, LoadData, LoadStreamTableProps, LoadTableProps, MergeTableProps, PartitionType, QueryInput, Table, TableDefinition, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -4,7 +4,7 @@ import { BQDate, decodeBQDate, encodeBQDate, zLuxonDate } from "../_shared/field
4
4
  import { BQDateTime, decodeBQDateTime, encodeBQDateTime, zLuxonDateTime } from "../_shared/field/bqDateTime.mjs";
5
5
  import { BQFieldMode, BQFieldModeSchema } from "../_shared/field/bqFieldMode.mjs";
6
6
  import { BQFieldType, BQFieldTypeSchema } from "../_shared/field/bqFieldType.mjs";
7
- import { BQFloat } from "../_shared/field/bqFloat.mjs";
7
+ import { zBQFloat } from "../_shared/field/bqFloat.mjs";
8
8
  import { zBQInt } from "../_shared/field/bqInt.mjs";
9
9
  import { BQInt64, zBQInt64 } from "../_shared/field/bqInt64.mjs";
10
10
  import { BQNumeric, zBQNumeric } from "../_shared/field/bqNumeric.mjs";
@@ -20,4 +20,4 @@ import { zodToBQSchema } from "../_shared/zodToBQDefinition.mjs";
20
20
  import "../_shared/index.mjs";
21
21
  import { GoogleCloudBigquery } from "./GoogleCloudBigquery.mjs";
22
22
  import { getHandlerPath } from "./getHandlerPath.mjs";
23
- export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQFloat, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, GoogleCloudBigquery, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
23
+ export { BQBool, BQBytes, BQDate, BQDateTime, BQFieldMode, BQFieldModeSchema, BQFieldType, BQFieldTypeSchema, BQInt64, BQNumeric, BQString, BQTime, BQTimestamp, GoogleCloudBigquery, countryBQRow, decodeBQDate, decodeBQDateTime, encodeBQDate, encodeBQDateTime, getHandlerPath, googleAdsAccountBQRow, googleCloudBQRow, languageBQRow, partitionType, zBQBytes, zBQFloat, zBQInt, zBQInt64, zBQNumeric, zBQTime, zLuxonDate, zLuxonDateTime, zodToBQSchema };
@@ -2,16 +2,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_lodash__shared_set = require("./set.cjs");
3
3
  const require_lodash__shared_isObject = require("./isObject.cjs");
4
4
  const require_lodash__shared_isDate = require("./isDate.cjs");
5
- const require_lodash__shared_merge = require("./merge.cjs");
6
- const require_lodash__shared_unescape = require("./unescape.cjs");
7
- const require_lodash__shared_trim = require("./trim.cjs");
8
5
  const require_lodash__shared_chunk = require("./chunk.cjs");
9
- const require_lodash__shared_flatten = require("./flatten.cjs");
10
6
  const require_lodash__shared_findKey = require("./findKey.cjs");
7
+ const require_lodash__shared_flatten = require("./flatten.cjs");
8
+ const require_lodash__shared_trim = require("./trim.cjs");
11
9
  const require_lodash__shared_isEmpty = require("./isEmpty.cjs");
12
10
  const require_lodash__shared_isEqual = require("./isEqual.cjs");
13
11
  const require_lodash__shared_isFunction = require("./isFunction.cjs");
12
+ const require_lodash__shared_merge = require("./merge.cjs");
14
13
  const require_lodash__shared_orderBy = require("./orderBy.cjs");
14
+ const require_lodash__shared_unescape = require("./unescape.cjs");
15
15
  const require_lodash__shared_uniq = require("./uniq.cjs");
16
16
  const require_lodash__shared_uniqBy = require("./uniqBy.cjs");
17
17
  exports.chunk = require_lodash__shared_chunk.chunk;
@@ -1,16 +1,16 @@
1
1
  import { set } from "./set.mjs";
2
2
  import { isObject } from "./isObject.mjs";
3
3
  import { isDate } from "./isDate.mjs";
4
- import { merge } from "./merge.mjs";
5
- import { unescape } from "./unescape.mjs";
6
- import { trim } from "./trim.mjs";
7
4
  import { chunk } from "./chunk.mjs";
8
- import { flatten } from "./flatten.mjs";
9
5
  import { findKey } from "./findKey.mjs";
6
+ import { flatten } from "./flatten.mjs";
7
+ import { trim } from "./trim.mjs";
10
8
  import { isEmpty } from "./isEmpty.mjs";
11
9
  import { isEqual } from "./isEqual.mjs";
12
10
  import { isFunction } from "./isFunction.mjs";
11
+ import { merge } from "./merge.mjs";
13
12
  import { orderBy } from "./orderBy.mjs";
13
+ import { unescape } from "./unescape.mjs";
14
14
  import { uniq } from "./uniq.mjs";
15
15
  import { uniqBy } from "./uniqBy.mjs";
16
16
  export { chunk, findKey, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -2,16 +2,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_lodash__shared_set = require("../_shared/set.cjs");
3
3
  const require_lodash__shared_isObject = require("../_shared/isObject.cjs");
4
4
  const require_lodash__shared_isDate = require("../_shared/isDate.cjs");
5
- const require_lodash__shared_merge = require("../_shared/merge.cjs");
6
- const require_lodash__shared_unescape = require("../_shared/unescape.cjs");
7
- const require_lodash__shared_trim = require("../_shared/trim.cjs");
8
5
  const require_lodash__shared_chunk = require("../_shared/chunk.cjs");
9
- const require_lodash__shared_flatten = require("../_shared/flatten.cjs");
10
6
  const require_lodash__shared_findKey = require("../_shared/findKey.cjs");
7
+ const require_lodash__shared_flatten = require("../_shared/flatten.cjs");
8
+ const require_lodash__shared_trim = require("../_shared/trim.cjs");
11
9
  const require_lodash__shared_isEmpty = require("../_shared/isEmpty.cjs");
12
10
  const require_lodash__shared_isEqual = require("../_shared/isEqual.cjs");
13
11
  const require_lodash__shared_isFunction = require("../_shared/isFunction.cjs");
12
+ const require_lodash__shared_merge = require("../_shared/merge.cjs");
14
13
  const require_lodash__shared_orderBy = require("../_shared/orderBy.cjs");
14
+ const require_lodash__shared_unescape = require("../_shared/unescape.cjs");
15
15
  const require_lodash__shared_uniq = require("../_shared/uniq.cjs");
16
16
  const require_lodash__shared_uniqBy = require("../_shared/uniqBy.cjs");
17
17
  exports.chunk = require_lodash__shared_chunk.chunk;
@@ -1,16 +1,16 @@
1
1
  import { set } from "../_shared/set.mjs";
2
2
  import { isObject } from "../_shared/isObject.mjs";
3
3
  import { isDate } from "../_shared/isDate.mjs";
4
- import { merge } from "../_shared/merge.mjs";
5
- import { unescape } from "../_shared/unescape.mjs";
6
- import { trim } from "../_shared/trim.mjs";
7
4
  import { chunk } from "../_shared/chunk.mjs";
8
- import { flatten } from "../_shared/flatten.mjs";
9
5
  import { findKey } from "../_shared/findKey.mjs";
6
+ import { flatten } from "../_shared/flatten.mjs";
7
+ import { trim } from "../_shared/trim.mjs";
10
8
  import { isEmpty } from "../_shared/isEmpty.mjs";
11
9
  import { isEqual } from "../_shared/isEqual.mjs";
12
10
  import { isFunction } from "../_shared/isFunction.mjs";
11
+ import { merge } from "../_shared/merge.mjs";
13
12
  import { orderBy } from "../_shared/orderBy.mjs";
13
+ import { unescape } from "../_shared/unescape.mjs";
14
14
  import { uniq } from "../_shared/uniq.mjs";
15
15
  import { uniqBy } from "../_shared/uniqBy.mjs";
16
16
  export { chunk, findKey, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -2,16 +2,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_lodash__shared_set = require("../_shared/set.cjs");
3
3
  const require_lodash__shared_isObject = require("../_shared/isObject.cjs");
4
4
  const require_lodash__shared_isDate = require("../_shared/isDate.cjs");
5
- const require_lodash__shared_merge = require("../_shared/merge.cjs");
6
- const require_lodash__shared_unescape = require("../_shared/unescape.cjs");
7
- const require_lodash__shared_trim = require("../_shared/trim.cjs");
8
5
  const require_lodash__shared_chunk = require("../_shared/chunk.cjs");
9
- const require_lodash__shared_flatten = require("../_shared/flatten.cjs");
10
6
  const require_lodash__shared_findKey = require("../_shared/findKey.cjs");
7
+ const require_lodash__shared_flatten = require("../_shared/flatten.cjs");
8
+ const require_lodash__shared_trim = require("../_shared/trim.cjs");
11
9
  const require_lodash__shared_isEmpty = require("../_shared/isEmpty.cjs");
12
10
  const require_lodash__shared_isEqual = require("../_shared/isEqual.cjs");
13
11
  const require_lodash__shared_isFunction = require("../_shared/isFunction.cjs");
12
+ const require_lodash__shared_merge = require("../_shared/merge.cjs");
14
13
  const require_lodash__shared_orderBy = require("../_shared/orderBy.cjs");
14
+ const require_lodash__shared_unescape = require("../_shared/unescape.cjs");
15
15
  const require_lodash__shared_uniq = require("../_shared/uniq.cjs");
16
16
  const require_lodash__shared_uniqBy = require("../_shared/uniqBy.cjs");
17
17
  exports.chunk = require_lodash__shared_chunk.chunk;
@@ -1,16 +1,16 @@
1
1
  import { set } from "../_shared/set.mjs";
2
2
  import { isObject } from "../_shared/isObject.mjs";
3
3
  import { isDate } from "../_shared/isDate.mjs";
4
- import { merge } from "../_shared/merge.mjs";
5
- import { unescape } from "../_shared/unescape.mjs";
6
- import { trim } from "../_shared/trim.mjs";
7
4
  import { chunk } from "../_shared/chunk.mjs";
8
- import { flatten } from "../_shared/flatten.mjs";
9
5
  import { findKey } from "../_shared/findKey.mjs";
6
+ import { flatten } from "../_shared/flatten.mjs";
7
+ import { trim } from "../_shared/trim.mjs";
10
8
  import { isEmpty } from "../_shared/isEmpty.mjs";
11
9
  import { isEqual } from "../_shared/isEqual.mjs";
12
10
  import { isFunction } from "../_shared/isFunction.mjs";
11
+ import { merge } from "../_shared/merge.mjs";
13
12
  import { orderBy } from "../_shared/orderBy.mjs";
13
+ import { unescape } from "../_shared/unescape.mjs";
14
14
  import { uniq } from "../_shared/uniq.mjs";
15
15
  import { uniqBy } from "../_shared/uniqBy.mjs";
16
16
  export { chunk, findKey, flatten, isDate, isEmpty, isEqual, isFunction, isObject, merge, orderBy, set, trim, unescape, uniq, uniqBy };
@@ -4,6 +4,7 @@ const require_file_server_createDirectory = require("../../file/server/createDir
4
4
  let ky = require("ky");
5
5
  ky = require_runtime.__toESM(ky);
6
6
  let stream = require("stream");
7
+ let stream_promises = require("stream/promises");
7
8
  let fs = require("fs");
8
9
  //#region src/url/server/writeUrlContents.ts
9
10
  /**
@@ -11,21 +12,9 @@ let fs = require("fs");
11
12
  */
12
13
  const writeUrlContents = async (filePath, url) => {
13
14
  await require_file_server_createDirectory.createDirectory(filePath);
14
- const writer = (0, fs.createWriteStream)(filePath);
15
15
  const response = await ky.default.get(url);
16
- const stream$1 = stream.Readable.fromWeb(response.body);
17
- await new Promise((resolve, reject) => {
18
- stream$1.pipe(writer);
19
- let error = null;
20
- writer.on("error", (err) => {
21
- error = err;
22
- writer.close();
23
- reject(err);
24
- });
25
- writer.on("close", () => {
26
- if (!error) resolve();
27
- });
28
- });
16
+ if (!response.body) throw new Error(`No response body for ${url}`);
17
+ await (0, stream_promises.pipeline)(stream.Readable.fromWeb(response.body), (0, fs.createWriteStream)(filePath));
29
18
  };
30
19
  //#endregion
31
20
  exports.writeUrlContents = writeUrlContents;
@@ -1,6 +1,7 @@
1
1
  import { createDirectory } from "../../file/server/createDirectory.mjs";
2
2
  import ky from "ky";
3
3
  import { Readable } from "stream";
4
+ import { pipeline } from "stream/promises";
4
5
  import { createWriteStream } from "fs";
5
6
  //#region src/url/server/writeUrlContents.ts
6
7
  /**
@@ -8,21 +9,9 @@ import { createWriteStream } from "fs";
8
9
  */
9
10
  const writeUrlContents = async (filePath, url) => {
10
11
  await createDirectory(filePath);
11
- const writer = createWriteStream(filePath);
12
12
  const response = await ky.get(url);
13
- const stream = Readable.fromWeb(response.body);
14
- await new Promise((resolve, reject) => {
15
- stream.pipe(writer);
16
- let error = null;
17
- writer.on("error", (err) => {
18
- error = err;
19
- writer.close();
20
- reject(err);
21
- });
22
- writer.on("close", () => {
23
- if (!error) resolve();
24
- });
25
- });
13
+ if (!response.body) throw new Error(`No response body for ${url}`);
14
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(filePath));
26
15
  };
27
16
  //#endregion
28
17
  export { writeUrlContents };
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xlsx__shared_column = require("./column.cjs");
3
3
  const require_xlsx__shared_cell = require("./cell.cjs");
4
- const require_zip__shared_ZipArchive = require("../../zip/_shared/ZipArchive.cjs");
5
4
  const require_xlsx__shared_sheet = require("./sheet.cjs");
5
+ const require_zip__shared_ZipArchive = require("../../zip/_shared/ZipArchive.cjs");
6
6
  //#region src/xlsx/_shared/createXlsx.ts
7
7
  /**
8
8
  * Builds a complete .xlsx workbook from scratch, using hand-written OOXML rather
@@ -1,7 +1,7 @@
1
1
  import { getColumLetter, getColumnWidth } from "./column.mjs";
2
2
  import { buildCellXml, getCellValue, getEscapedXml } from "./cell.mjs";
3
- import { ZipArchive } from "../../zip/_shared/ZipArchive.mjs";
4
3
  import { getUniqueSheetNames } from "./sheet.mjs";
4
+ import { ZipArchive } from "../../zip/_shared/ZipArchive.mjs";
5
5
  //#region src/xlsx/_shared/createXlsx.ts
6
6
  /**
7
7
  * Builds a complete .xlsx workbook from scratch, using hand-written OOXML rather
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "3.2.10",
5
- "packageManager": "yarn@4.18.0",
4
+ "version": "3.2.11",
5
+ "packageManager": "yarn@4.18.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -196,19 +196,19 @@
196
196
  },
197
197
  "devDependencies": {
198
198
  "@1password/sdk": "^0.5.0",
199
- "@aws-sdk/client-cloudwatch": "^3.1141.0",
200
- "@aws-sdk/client-cloudwatch-logs": "^3.1141.0",
201
- "@aws-sdk/client-ec2": "^3.1141.0",
202
- "@aws-sdk/client-ecs": "^3.1141.0",
203
- "@aws-sdk/client-glue": "^3.1141.0",
204
- "@aws-sdk/client-lambda": "^3.1141.0",
205
- "@aws-sdk/client-s3": "^3.1141.0",
206
- "@aws-sdk/client-sesv2": "^3.1141.0",
207
- "@aws-sdk/client-sqs": "^3.1141.0",
208
- "@aws-sdk/client-ssm": "^3.1141.0",
209
- "@aws-sdk/client-sts": "^3.1141.0",
210
- "@aws-sdk/lib-storage": "^3.1141.0",
211
- "@aws-sdk/s3-request-presigner": "^3.1141.0",
199
+ "@aws-sdk/client-cloudwatch": "^3.1145.0",
200
+ "@aws-sdk/client-cloudwatch-logs": "^3.1145.0",
201
+ "@aws-sdk/client-ec2": "^3.1145.0",
202
+ "@aws-sdk/client-ecs": "^3.1145.0",
203
+ "@aws-sdk/client-glue": "^3.1145.0",
204
+ "@aws-sdk/client-lambda": "^3.1145.0",
205
+ "@aws-sdk/client-s3": "^3.1145.0",
206
+ "@aws-sdk/client-sesv2": "^3.1145.0",
207
+ "@aws-sdk/client-sqs": "^3.1145.0",
208
+ "@aws-sdk/client-ssm": "^3.1145.0",
209
+ "@aws-sdk/client-sts": "^3.1145.0",
210
+ "@aws-sdk/lib-storage": "^3.1145.0",
211
+ "@aws-sdk/s3-request-presigner": "^3.1145.0",
212
212
  "@aws-sdk/types": "^3.974.6",
213
213
  "@babel/core": "^8.0.6",
214
214
  "@babel/preset-env": "^8.0.6",
@@ -218,28 +218,28 @@
218
218
  "@google-cloud/storage": "^8.2.0",
219
219
  "@googleapis/drive": "^26.0.1",
220
220
  "@googleapis/sheets": "^18.0.1",
221
- "@planetscale/database": "^1.20.1",
221
+ "@planetscale/database": "^1.20.2",
222
222
  "@prisma/adapter-mariadb": "^7.10.0",
223
223
  "@prisma/adapter-pg": "^7.10.0",
224
224
  "@prisma/adapter-planetscale": "^7.10.0",
225
225
  "@prisma/client": "^7.10.0",
226
226
  "@types/fs-extra": "^11.0.4",
227
227
  "@types/jest": "^30.0.0",
228
- "@types/luxon": "^3.7.5",
229
- "@types/node": "^24.19.0",
228
+ "@types/luxon": "^3.7.6",
229
+ "@types/node": "^24.19.1",
230
230
  "@types/react": "^19.3.0",
231
231
  "@vercel/oidc": "^3.8.9",
232
232
  "@vercel/oidc-aws-credentials-provider": "^3.3.9",
233
233
  "babel-jest": "30.5.2",
234
- "dotenv": "^18.0.4",
234
+ "dotenv": "^18.0.5",
235
235
  "drizzle-orm": "1.0.0-beta.22",
236
236
  "gaxios": "^8.1.0",
237
237
  "google-auth-library": "^11.1.0",
238
238
  "googleapis-common": "^9.1.0",
239
239
  "jest": "^30.5.2",
240
- "mysql2": "^3.24.4",
241
- "next": "^16.3.6",
242
- "pg": "^8.23.0",
240
+ "mysql2": "^3.24.5",
241
+ "next": "^16.3.8",
242
+ "pg": "^8.23.1",
243
243
  "react": "^19.3.0",
244
244
  "react-intersection-observer": "^11.0.1",
245
245
  "stream-json": "^3.7.0",
@@ -995,10 +995,6 @@
995
995
  "import": "./dist/googleCloud/bigquery/_shared/field/bqInt64.mjs",
996
996
  "require": "./dist/googleCloud/bigquery/_shared/field/bqInt64.cjs"
997
997
  },
998
- "./googleCloud/bigquery/_shared/field/bqNullableString": {
999
- "import": "./dist/googleCloud/bigquery/_shared/field/bqNullableString.mjs",
1000
- "require": "./dist/googleCloud/bigquery/_shared/field/bqNullableString.cjs"
1001
- },
1002
998
  "./googleCloud/bigquery/_shared/field/bqNumeric": {
1003
999
  "import": "./dist/googleCloud/bigquery/_shared/field/bqNumeric.mjs",
1004
1000
  "require": "./dist/googleCloud/bigquery/_shared/field/bqNumeric.cjs"
@@ -1007,6 +1003,10 @@
1007
1003
  "import": "./dist/googleCloud/bigquery/_shared/field/bqString.mjs",
1008
1004
  "require": "./dist/googleCloud/bigquery/_shared/field/bqString.cjs"
1009
1005
  },
1006
+ "./googleCloud/bigquery/_shared/field/bqStringNullable": {
1007
+ "import": "./dist/googleCloud/bigquery/_shared/field/bqStringNullable.mjs",
1008
+ "require": "./dist/googleCloud/bigquery/_shared/field/bqStringNullable.cjs"
1009
+ },
1010
1010
  "./googleCloud/bigquery/_shared/field/bqTime": {
1011
1011
  "import": "./dist/googleCloud/bigquery/_shared/field/bqTime.mjs",
1012
1012
  "require": "./dist/googleCloud/bigquery/_shared/field/bqTime.cjs"