@stripe/extensibility-dev-tools 0.24.2 → 0.24.3

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.
@@ -1785,10 +1785,11 @@ function mapActions(actions) {
1785
1785
  }
1786
1786
  function mapProperties(schema) {
1787
1787
  const result = {};
1788
- const requiredSet = new Set(schema?.required ?? []);
1789
- if (!schema?.properties) return result;
1790
- const defs = schema.$defs ?? {};
1791
- for (const [key, propSchema] of Object.entries(schema.properties)) {
1788
+ const resolvedSchema = schema === null || schema === void 0 ? schema : resolveRef(schema, schema.$defs ?? {});
1789
+ const requiredSet = new Set(resolvedSchema?.required ?? []);
1790
+ if (!resolvedSchema?.properties) return result;
1791
+ const defs = resolvedSchema.$defs ?? {};
1792
+ for (const [key, propSchema] of Object.entries(resolvedSchema.properties)) {
1792
1793
  result[key] = toFieldSchema(resolveRef(propSchema, defs), requiredSet.has(key));
1793
1794
  }
1794
1795
  return result;
@@ -1832,10 +1833,11 @@ function toFieldSchema(schema, required) {
1832
1833
  fieldSchema.valuesPresence = FieldPresence.PRESENT;
1833
1834
  }
1834
1835
  if (schema.default !== void 0) {
1835
- if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
1836
- throw new Error(
1837
- `Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1838
- );
1836
+ if (dataType === DataType.ENUM_TYPE && enumValues) {
1837
+ validateEnumDefault(schema.default, enumValues);
1838
+ }
1839
+ if (dataType === DataType.DATETIME_TYPE) {
1840
+ validateDatetimeDefault(schema.default);
1839
1841
  }
1840
1842
  fieldSchema.default = toDefaultValue(schema.default, dataType);
1841
1843
  }
@@ -1849,7 +1851,6 @@ function resolveDataType(schema, enumValues, refTarget) {
1849
1851
  if (schema.format === "date-time") return DataType.DATETIME_TYPE;
1850
1852
  return DataType.STRING_TYPE;
1851
1853
  case "integer":
1852
- case "number":
1853
1854
  return DataType.INTEGER_TYPE;
1854
1855
  case "boolean":
1855
1856
  return DataType.BOOLEAN_TYPE;
@@ -1886,14 +1887,31 @@ function extractSingleLiteral(schema) {
1886
1887
  return null;
1887
1888
  }
1888
1889
  function extractEnumValues(schema) {
1889
- if (schema.enum) {
1890
+ if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) {
1890
1891
  return schema.enum.map(String);
1891
1892
  }
1892
- if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every((item) => "const" in item)) {
1893
+ if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
1894
+ (item) => "const" in item && typeof item.const === "string"
1895
+ )) {
1893
1896
  return schema.oneOf.map((item) => String(item.const));
1894
1897
  }
1895
1898
  return null;
1896
1899
  }
1900
+ function validateEnumDefault(value, enumValues) {
1901
+ if (typeof value !== "string" || !enumValues.includes(value)) {
1902
+ throw new Error(
1903
+ `Default value ${JSON.stringify(value)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1904
+ );
1905
+ }
1906
+ }
1907
+ var DATETIME_UTC_MS_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|\+00:00)$/;
1908
+ function validateDatetimeDefault(value) {
1909
+ if (typeof value !== "string" || !DATETIME_UTC_MS_RE.test(value)) {
1910
+ throw new Error(
1911
+ `Default value ${JSON.stringify(value)} is not a valid ISO 8601 UTC datetime with millisecond precision. Expected format: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss+00:00`
1912
+ );
1913
+ }
1914
+ }
1897
1915
  function toValueBoundary(value) {
1898
1916
  if (!Number.isInteger(value)) {
1899
1917
  throw new Error(
@@ -1909,7 +1927,15 @@ function toDefaultValue(value, dataType) {
1909
1927
  if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
1910
1928
  return { stringDefault: value };
1911
1929
  }
1930
+ if (dataType === DataType.DATETIME_TYPE && typeof value === "string") {
1931
+ return { stringDefault: value };
1932
+ }
1912
1933
  if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
1934
+ if (!Number.isInteger(value)) {
1935
+ throw new Error(
1936
+ `Integer default values must be whole numbers, got ${JSON.stringify(value)}.`
1937
+ );
1938
+ }
1913
1939
  return { integerDefault: value };
1914
1940
  }
1915
1941
  if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
@@ -1945,7 +1971,7 @@ async function analyzeAndInjectManifest(options) {
1945
1971
  (diagnostic) => diagnostic.severity === "error"
1946
1972
  );
1947
1973
  if (errorDiagnostics.length > 0) {
1948
- const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("; ");
1974
+ const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("\n");
1949
1975
  throw new Error(details);
1950
1976
  }
1951
1977
  const coPackageJsonPath = path2.join(projectRoot, "custom-objects", "package.json");
@@ -1762,10 +1762,11 @@ function mapActions(actions) {
1762
1762
  }
1763
1763
  function mapProperties(schema) {
1764
1764
  const result = {};
1765
- const requiredSet = new Set(schema?.required ?? []);
1766
- if (!schema?.properties) return result;
1767
- const defs = schema.$defs ?? {};
1768
- for (const [key, propSchema] of Object.entries(schema.properties)) {
1765
+ const resolvedSchema = schema === null || schema === void 0 ? schema : resolveRef(schema, schema.$defs ?? {});
1766
+ const requiredSet = new Set(resolvedSchema?.required ?? []);
1767
+ if (!resolvedSchema?.properties) return result;
1768
+ const defs = resolvedSchema.$defs ?? {};
1769
+ for (const [key, propSchema] of Object.entries(resolvedSchema.properties)) {
1769
1770
  result[key] = toFieldSchema(resolveRef(propSchema, defs), requiredSet.has(key));
1770
1771
  }
1771
1772
  return result;
@@ -1809,10 +1810,11 @@ function toFieldSchema(schema, required) {
1809
1810
  fieldSchema.valuesPresence = FieldPresence.PRESENT;
1810
1811
  }
1811
1812
  if (schema.default !== void 0) {
1812
- if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
1813
- throw new Error(
1814
- `Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1815
- );
1813
+ if (dataType === DataType.ENUM_TYPE && enumValues) {
1814
+ validateEnumDefault(schema.default, enumValues);
1815
+ }
1816
+ if (dataType === DataType.DATETIME_TYPE) {
1817
+ validateDatetimeDefault(schema.default);
1816
1818
  }
1817
1819
  fieldSchema.default = toDefaultValue(schema.default, dataType);
1818
1820
  }
@@ -1826,7 +1828,6 @@ function resolveDataType(schema, enumValues, refTarget) {
1826
1828
  if (schema.format === "date-time") return DataType.DATETIME_TYPE;
1827
1829
  return DataType.STRING_TYPE;
1828
1830
  case "integer":
1829
- case "number":
1830
1831
  return DataType.INTEGER_TYPE;
1831
1832
  case "boolean":
1832
1833
  return DataType.BOOLEAN_TYPE;
@@ -1863,14 +1864,31 @@ function extractSingleLiteral(schema) {
1863
1864
  return null;
1864
1865
  }
1865
1866
  function extractEnumValues(schema) {
1866
- if (schema.enum) {
1867
+ if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) {
1867
1868
  return schema.enum.map(String);
1868
1869
  }
1869
- if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every((item) => "const" in item)) {
1870
+ if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
1871
+ (item) => "const" in item && typeof item.const === "string"
1872
+ )) {
1870
1873
  return schema.oneOf.map((item) => String(item.const));
1871
1874
  }
1872
1875
  return null;
1873
1876
  }
1877
+ function validateEnumDefault(value, enumValues) {
1878
+ if (typeof value !== "string" || !enumValues.includes(value)) {
1879
+ throw new Error(
1880
+ `Default value ${JSON.stringify(value)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1881
+ );
1882
+ }
1883
+ }
1884
+ var DATETIME_UTC_MS_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|\+00:00)$/;
1885
+ function validateDatetimeDefault(value) {
1886
+ if (typeof value !== "string" || !DATETIME_UTC_MS_RE.test(value)) {
1887
+ throw new Error(
1888
+ `Default value ${JSON.stringify(value)} is not a valid ISO 8601 UTC datetime with millisecond precision. Expected format: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss+00:00`
1889
+ );
1890
+ }
1891
+ }
1874
1892
  function toValueBoundary(value) {
1875
1893
  if (!Number.isInteger(value)) {
1876
1894
  throw new Error(
@@ -1886,7 +1904,15 @@ function toDefaultValue(value, dataType) {
1886
1904
  if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
1887
1905
  return { stringDefault: value };
1888
1906
  }
1907
+ if (dataType === DataType.DATETIME_TYPE && typeof value === "string") {
1908
+ return { stringDefault: value };
1909
+ }
1889
1910
  if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
1911
+ if (!Number.isInteger(value)) {
1912
+ throw new Error(
1913
+ `Integer default values must be whole numbers, got ${JSON.stringify(value)}.`
1914
+ );
1915
+ }
1890
1916
  return { integerDefault: value };
1891
1917
  }
1892
1918
  if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
@@ -1922,7 +1948,7 @@ async function analyzeAndInjectManifest(options) {
1922
1948
  (diagnostic) => diagnostic.severity === "error"
1923
1949
  );
1924
1950
  if (errorDiagnostics.length > 0) {
1925
- const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("; ");
1951
+ const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("\n");
1926
1952
  throw new Error(details);
1927
1953
  }
1928
1954
  const coPackageJsonPath = path2.join(projectRoot, "custom-objects", "package.json");
@@ -28,6 +28,7 @@ var import_node_child_process2 = require("child_process");
28
28
  var fs3 = __toESM(require("fs"), 1);
29
29
  var os2 = __toESM(require("os"), 1);
30
30
  var path3 = __toESM(require("path"), 1);
31
+ var import_extensibility_tool_utils8 = require("@stripe/extensibility-tool-utils");
31
32
 
32
33
  // src/custom-objects/build-definitions.ts
33
34
  var fs2 = __toESM(require("fs"), 1);
@@ -1788,10 +1789,11 @@ function mapActions(actions) {
1788
1789
  }
1789
1790
  function mapProperties(schema) {
1790
1791
  const result = {};
1791
- const requiredSet = new Set(schema?.required ?? []);
1792
- if (!schema?.properties) return result;
1793
- const defs = schema.$defs ?? {};
1794
- for (const [key, propSchema] of Object.entries(schema.properties)) {
1792
+ const resolvedSchema = schema === null || schema === void 0 ? schema : resolveRef(schema, schema.$defs ?? {});
1793
+ const requiredSet = new Set(resolvedSchema?.required ?? []);
1794
+ if (!resolvedSchema?.properties) return result;
1795
+ const defs = resolvedSchema.$defs ?? {};
1796
+ for (const [key, propSchema] of Object.entries(resolvedSchema.properties)) {
1795
1797
  result[key] = toFieldSchema(resolveRef(propSchema, defs), requiredSet.has(key));
1796
1798
  }
1797
1799
  return result;
@@ -1835,10 +1837,11 @@ function toFieldSchema(schema, required) {
1835
1837
  fieldSchema.valuesPresence = FieldPresence.PRESENT;
1836
1838
  }
1837
1839
  if (schema.default !== void 0) {
1838
- if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
1839
- throw new Error(
1840
- `Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1841
- );
1840
+ if (dataType === DataType.ENUM_TYPE && enumValues) {
1841
+ validateEnumDefault(schema.default, enumValues);
1842
+ }
1843
+ if (dataType === DataType.DATETIME_TYPE) {
1844
+ validateDatetimeDefault(schema.default);
1842
1845
  }
1843
1846
  fieldSchema.default = toDefaultValue(schema.default, dataType);
1844
1847
  }
@@ -1852,7 +1855,6 @@ function resolveDataType(schema, enumValues, refTarget) {
1852
1855
  if (schema.format === "date-time") return DataType.DATETIME_TYPE;
1853
1856
  return DataType.STRING_TYPE;
1854
1857
  case "integer":
1855
- case "number":
1856
1858
  return DataType.INTEGER_TYPE;
1857
1859
  case "boolean":
1858
1860
  return DataType.BOOLEAN_TYPE;
@@ -1889,14 +1891,31 @@ function extractSingleLiteral(schema) {
1889
1891
  return null;
1890
1892
  }
1891
1893
  function extractEnumValues(schema) {
1892
- if (schema.enum) {
1894
+ if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) {
1893
1895
  return schema.enum.map(String);
1894
1896
  }
1895
- if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every((item) => "const" in item)) {
1897
+ if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
1898
+ (item) => "const" in item && typeof item.const === "string"
1899
+ )) {
1896
1900
  return schema.oneOf.map((item) => String(item.const));
1897
1901
  }
1898
1902
  return null;
1899
1903
  }
1904
+ function validateEnumDefault(value, enumValues) {
1905
+ if (typeof value !== "string" || !enumValues.includes(value)) {
1906
+ throw new Error(
1907
+ `Default value ${JSON.stringify(value)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1908
+ );
1909
+ }
1910
+ }
1911
+ var DATETIME_UTC_MS_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|\+00:00)$/;
1912
+ function validateDatetimeDefault(value) {
1913
+ if (typeof value !== "string" || !DATETIME_UTC_MS_RE.test(value)) {
1914
+ throw new Error(
1915
+ `Default value ${JSON.stringify(value)} is not a valid ISO 8601 UTC datetime with millisecond precision. Expected format: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss+00:00`
1916
+ );
1917
+ }
1918
+ }
1900
1919
  function toValueBoundary(value) {
1901
1920
  if (!Number.isInteger(value)) {
1902
1921
  throw new Error(
@@ -1912,7 +1931,15 @@ function toDefaultValue(value, dataType) {
1912
1931
  if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
1913
1932
  return { stringDefault: value };
1914
1933
  }
1934
+ if (dataType === DataType.DATETIME_TYPE && typeof value === "string") {
1935
+ return { stringDefault: value };
1936
+ }
1915
1937
  if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
1938
+ if (!Number.isInteger(value)) {
1939
+ throw new Error(
1940
+ `Integer default values must be whole numbers, got ${JSON.stringify(value)}.`
1941
+ );
1942
+ }
1916
1943
  return { integerDefault: value };
1917
1944
  }
1918
1945
  if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
@@ -1948,7 +1975,7 @@ async function analyzeAndInjectManifest(options) {
1948
1975
  (diagnostic) => diagnostic.severity === "error"
1949
1976
  );
1950
1977
  if (errorDiagnostics.length > 0) {
1951
- const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("; ");
1978
+ const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("\n");
1952
1979
  throw new Error(details);
1953
1980
  }
1954
1981
  const coPackageJsonPath = path2.join(projectRoot, "custom-objects", "package.json");
@@ -2085,16 +2112,18 @@ function readPackageDependencies(packageJsonPath) {
2085
2112
  }
2086
2113
 
2087
2114
  // src/bin/create-upload-image.ts
2115
+ var logger = (0, import_extensibility_tool_utils8._createLogger)({ name: "create-upload-image" });
2088
2116
  async function main() {
2117
+ const ctx = (0, import_extensibility_tool_utils8._createCliContext)();
2089
2118
  const targetPath = process.argv[2];
2090
2119
  if (!targetPath) {
2091
- console.error("Usage: create-upload-image <target-path>");
2120
+ ctx.ux.error("Usage: create-upload-image <target-path>");
2092
2121
  process.exit(1);
2093
2122
  }
2094
2123
  let state = null;
2095
2124
  const manifestPath = "stripe-app.yaml";
2096
2125
  if (fs3.existsSync(manifestPath)) {
2097
- state = await analyzeAndInjectManifest({ manifestPath });
2126
+ state = await analyzeAndInjectManifest({ manifestPath, context: ctx });
2098
2127
  }
2099
2128
  fs3.mkdirSync(targetPath, { recursive: true });
2100
2129
  const tarball = path3.join(os2.tmpdir(), `upload-image-${String(Date.now())}.tgz`);
@@ -2127,7 +2156,7 @@ async function main() {
2127
2156
  }
2128
2157
  }
2129
2158
  if (state) {
2130
- await writeCustomObjectArtifacts({ targetPath }, state);
2159
+ await writeCustomObjectArtifacts({ targetPath, context: ctx }, state);
2131
2160
  }
2132
2161
  const imageMetadata = JSON.stringify(
2133
2162
  { image: { version: "1.0", built: (/* @__PURE__ */ new Date()).toISOString() } },
@@ -2137,6 +2166,6 @@ async function main() {
2137
2166
  fs3.writeFileSync(path3.join(targetPath, ".image.json"), imageMetadata + "\n");
2138
2167
  }
2139
2168
  main().catch((err) => {
2140
- console.error(err);
2169
+ logger.error({ err }, "Unexpected error");
2141
2170
  process.exit(1);
2142
2171
  });
@@ -5,6 +5,7 @@ import { execSync as execSync2 } from "child_process";
5
5
  import * as fs3 from "fs";
6
6
  import * as os2 from "os";
7
7
  import * as path3 from "path";
8
+ import { _createCliContext as _createCliContext3, _createLogger } from "@stripe/extensibility-tool-utils";
8
9
 
9
10
  // src/custom-objects/build-definitions.ts
10
11
  import * as fs2 from "fs";
@@ -1765,10 +1766,11 @@ function mapActions(actions) {
1765
1766
  }
1766
1767
  function mapProperties(schema) {
1767
1768
  const result = {};
1768
- const requiredSet = new Set(schema?.required ?? []);
1769
- if (!schema?.properties) return result;
1770
- const defs = schema.$defs ?? {};
1771
- for (const [key, propSchema] of Object.entries(schema.properties)) {
1769
+ const resolvedSchema = schema === null || schema === void 0 ? schema : resolveRef(schema, schema.$defs ?? {});
1770
+ const requiredSet = new Set(resolvedSchema?.required ?? []);
1771
+ if (!resolvedSchema?.properties) return result;
1772
+ const defs = resolvedSchema.$defs ?? {};
1773
+ for (const [key, propSchema] of Object.entries(resolvedSchema.properties)) {
1772
1774
  result[key] = toFieldSchema(resolveRef(propSchema, defs), requiredSet.has(key));
1773
1775
  }
1774
1776
  return result;
@@ -1812,10 +1814,11 @@ function toFieldSchema(schema, required) {
1812
1814
  fieldSchema.valuesPresence = FieldPresence.PRESENT;
1813
1815
  }
1814
1816
  if (schema.default !== void 0) {
1815
- if (dataType === DataType.ENUM_TYPE && enumValues && (typeof schema.default !== "string" || !enumValues.includes(schema.default))) {
1816
- throw new Error(
1817
- `Default value ${JSON.stringify(schema.default)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1818
- );
1817
+ if (dataType === DataType.ENUM_TYPE && enumValues) {
1818
+ validateEnumDefault(schema.default, enumValues);
1819
+ }
1820
+ if (dataType === DataType.DATETIME_TYPE) {
1821
+ validateDatetimeDefault(schema.default);
1819
1822
  }
1820
1823
  fieldSchema.default = toDefaultValue(schema.default, dataType);
1821
1824
  }
@@ -1829,7 +1832,6 @@ function resolveDataType(schema, enumValues, refTarget) {
1829
1832
  if (schema.format === "date-time") return DataType.DATETIME_TYPE;
1830
1833
  return DataType.STRING_TYPE;
1831
1834
  case "integer":
1832
- case "number":
1833
1835
  return DataType.INTEGER_TYPE;
1834
1836
  case "boolean":
1835
1837
  return DataType.BOOLEAN_TYPE;
@@ -1866,14 +1868,31 @@ function extractSingleLiteral(schema) {
1866
1868
  return null;
1867
1869
  }
1868
1870
  function extractEnumValues(schema) {
1869
- if (schema.enum) {
1871
+ if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) {
1870
1872
  return schema.enum.map(String);
1871
1873
  }
1872
- if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every((item) => "const" in item)) {
1874
+ if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0 && schema.oneOf.every(
1875
+ (item) => "const" in item && typeof item.const === "string"
1876
+ )) {
1873
1877
  return schema.oneOf.map((item) => String(item.const));
1874
1878
  }
1875
1879
  return null;
1876
1880
  }
1881
+ function validateEnumDefault(value, enumValues) {
1882
+ if (typeof value !== "string" || !enumValues.includes(value)) {
1883
+ throw new Error(
1884
+ `Default value ${JSON.stringify(value)} is not a valid enum value. Expected one of: ${enumValues.join(", ")}`
1885
+ );
1886
+ }
1887
+ }
1888
+ var DATETIME_UTC_MS_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|\+00:00)$/;
1889
+ function validateDatetimeDefault(value) {
1890
+ if (typeof value !== "string" || !DATETIME_UTC_MS_RE.test(value)) {
1891
+ throw new Error(
1892
+ `Default value ${JSON.stringify(value)} is not a valid ISO 8601 UTC datetime with millisecond precision. Expected format: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss+00:00`
1893
+ );
1894
+ }
1895
+ }
1877
1896
  function toValueBoundary(value) {
1878
1897
  if (!Number.isInteger(value)) {
1879
1898
  throw new Error(
@@ -1889,7 +1908,15 @@ function toDefaultValue(value, dataType) {
1889
1908
  if (dataType === DataType.ENUM_TYPE && typeof value === "string") {
1890
1909
  return { stringDefault: value };
1891
1910
  }
1911
+ if (dataType === DataType.DATETIME_TYPE && typeof value === "string") {
1912
+ return { stringDefault: value };
1913
+ }
1892
1914
  if (dataType === DataType.INTEGER_TYPE && typeof value === "number") {
1915
+ if (!Number.isInteger(value)) {
1916
+ throw new Error(
1917
+ `Integer default values must be whole numbers, got ${JSON.stringify(value)}.`
1918
+ );
1919
+ }
1893
1920
  return { integerDefault: value };
1894
1921
  }
1895
1922
  if (dataType === DataType.BOOLEAN_TYPE && typeof value === "boolean") {
@@ -1925,7 +1952,7 @@ async function analyzeAndInjectManifest(options) {
1925
1952
  (diagnostic) => diagnostic.severity === "error"
1926
1953
  );
1927
1954
  if (errorDiagnostics.length > 0) {
1928
- const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("; ");
1955
+ const details = errorDiagnostics.map((diagnostic) => diagnostic.message).join("\n");
1929
1956
  throw new Error(details);
1930
1957
  }
1931
1958
  const coPackageJsonPath = path2.join(projectRoot, "custom-objects", "package.json");
@@ -2062,16 +2089,18 @@ function readPackageDependencies(packageJsonPath) {
2062
2089
  }
2063
2090
 
2064
2091
  // src/bin/create-upload-image.ts
2092
+ var logger = _createLogger({ name: "create-upload-image" });
2065
2093
  async function main() {
2094
+ const ctx = _createCliContext3();
2066
2095
  const targetPath = process.argv[2];
2067
2096
  if (!targetPath) {
2068
- console.error("Usage: create-upload-image <target-path>");
2097
+ ctx.ux.error("Usage: create-upload-image <target-path>");
2069
2098
  process.exit(1);
2070
2099
  }
2071
2100
  let state = null;
2072
2101
  const manifestPath = "stripe-app.yaml";
2073
2102
  if (fs3.existsSync(manifestPath)) {
2074
- state = await analyzeAndInjectManifest({ manifestPath });
2103
+ state = await analyzeAndInjectManifest({ manifestPath, context: ctx });
2075
2104
  }
2076
2105
  fs3.mkdirSync(targetPath, { recursive: true });
2077
2106
  const tarball = path3.join(os2.tmpdir(), `upload-image-${String(Date.now())}.tgz`);
@@ -2104,7 +2133,7 @@ async function main() {
2104
2133
  }
2105
2134
  }
2106
2135
  if (state) {
2107
- await writeCustomObjectArtifacts({ targetPath }, state);
2136
+ await writeCustomObjectArtifacts({ targetPath, context: ctx }, state);
2108
2137
  }
2109
2138
  const imageMetadata = JSON.stringify(
2110
2139
  { image: { version: "1.0", built: (/* @__PURE__ */ new Date()).toISOString() } },
@@ -2114,6 +2143,6 @@ async function main() {
2114
2143
  fs3.writeFileSync(path3.join(targetPath, ".image.json"), imageMetadata + "\n");
2115
2144
  }
2116
2145
  main().catch((err) => {
2117
- console.error(err);
2146
+ logger.error({ err }, "Unexpected error");
2118
2147
  process.exit(1);
2119
2148
  });
@@ -1 +1 @@
1
- {"version":3,"file":"build-definitions.d.ts","sourceRoot":"","sources":["../../src/custom-objects/build-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,iBAAiB,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,KAAK,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGjF,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEvF,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,iBAAiB,CAAC,8BAA8B,CAAC;IAC/D,aAAa,EAAE,uBAAuB,EAAE,CAAC;IACzC,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAsGxC;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAmEf;AAED;;;;;;;GAOG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAef"}
1
+ {"version":3,"file":"build-definitions.d.ts","sourceRoot":"","sources":["../../src/custom-objects/build-definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,iBAAiB,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,KAAK,uBAAuB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGjF,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEvF,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,iBAAiB,CAAC,8BAA8B,CAAC;IAC/D,aAAa,EAAE,uBAAuB,EAAE,CAAC;IACzC,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAqGxC;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAmEf;AAED;;;;;;;GAOG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAef"}