@tinacms/graphql 2.4.1 → 2.4.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +42 -14
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -137,7 +137,7 @@ Visit [Tina's documentation](https://tina.io/docs/) to learn more.
137
137
  [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?url=https%3A%2F%2Ftinacms.org&text=I%20just%20checked%20out%20@tinacms%20on%20GitHub%20and%20it%20is%20sweet%21&hashtags=TinaCMS%2Cjamstack%2Cheadlesscms)
138
138
  [![Forum](https://shields.io/github/discussions/tinacms/tinacms)](https://github.com/tinacms/tinacms/discussions)
139
139
 
140
- Visit the [GitHub Discussions](https://github.com/tinacms/tinacms/discussions) or our [Community Discord](https://discord.com/invite/zumN63Ybpf) to ask questions, or look us up on on Twitter at [@tinacms](https://twitter.com/tinacms).
140
+ Visit the [GitHub Discussions](https://github.com/tinacms/tinacms/discussions) or our [Community Discord](https://discord.com/invite/zumN63Ybpf) to ask questions, or look us up on Twitter at [@tinacms](https://twitter.com/tinacms).
141
141
 
142
142
  ## Contributing
143
143
 
package/dist/index.js CHANGED
@@ -3028,14 +3028,31 @@ var validateField = async (field) => {
3028
3028
  });
3029
3029
  await schema.validate(field);
3030
3030
  const validField = await schema.cast(field);
3031
+ assertCheckboxGroupIsList(validField);
3031
3032
  return validField;
3032
3033
  };
3034
+ var assertCheckboxGroupIsList = (field) => {
3035
+ if (field.ui?.component === "checkbox-group" && !field.list) {
3036
+ throw new Error(
3037
+ `Field "${field.name}" uses "checkbox-group" without list: true at ${field.namespace.join(
3038
+ "."
3039
+ )}. Add list: true or use "select" instead.`
3040
+ );
3041
+ }
3042
+ if (field.type === "object" || field.type === "rich-text") {
3043
+ const nested = [
3044
+ ...field.type === "object" ? field.fields ?? [] : [],
3045
+ ...(field.templates ?? []).flatMap((template) => template.fields ?? [])
3046
+ ];
3047
+ nested.forEach(assertCheckboxGroupIsList);
3048
+ }
3049
+ };
3033
3050
 
3034
3051
  // package.json
3035
3052
  var package_default = {
3036
3053
  name: "@tinacms/graphql",
3037
3054
  type: "module",
3038
- version: "2.4.1",
3055
+ version: "2.4.3",
3039
3056
  main: "dist/index.js",
3040
3057
  module: "./dist/index.js",
3041
3058
  files: [
@@ -3808,6 +3825,18 @@ var REFS_COLLECTIONS_SORT_KEY = "__refs__";
3808
3825
  var REFS_REFERENCE_FIELD = "__tina_ref__";
3809
3826
  var REFS_PATH_FIELD = "__tina_ref_path__";
3810
3827
  var DEFAULT_NUMERIC_LPAD = 4;
3828
+ var ensureUTC = (value) => {
3829
+ const s = String(value);
3830
+ if (s.includes("T") && !/[Zz]|[+-]\d{2}:\d{2}$/.test(s)) {
3831
+ return `${s}Z`;
3832
+ }
3833
+ return s;
3834
+ };
3835
+ var parseDatetimeUTC = (value) => {
3836
+ const n = Number(value);
3837
+ const d = Number.isNaN(n) ? new Date(ensureUTC(String(value))) : new Date(n);
3838
+ return Number.isNaN(d.getTime()) ? String(value) : d.toISOString();
3839
+ };
3811
3840
  var applyPadding = (input, pad) => {
3812
3841
  if (pad) {
3813
3842
  if (Array.isArray(input)) {
@@ -3854,7 +3883,7 @@ var makeKeyForField = (definition, data, stringEscaper2, maxStringLength = 100)
3854
3883
  const rawValue = data[field.name];
3855
3884
  let resolvedValue;
3856
3885
  if (field.type === "datetime") {
3857
- resolvedValue = String(new Date(rawValue).getTime());
3886
+ resolvedValue = parseDatetimeUTC(rawValue);
3858
3887
  } else {
3859
3888
  if (field.type === "string") {
3860
3889
  const escapedString = stringEscaper2(rawValue);
@@ -3885,23 +3914,23 @@ var coerceFilterChainOperands = (filterChain, escapeString = stringEscaper) => {
3885
3914
  if (filter.leftOperand !== void 0) {
3886
3915
  result.push({
3887
3916
  ...filter,
3888
- rightOperand: new Date(filter.rightOperand).getTime(),
3889
- leftOperand: new Date(
3917
+ rightOperand: parseDatetimeUTC(filter.rightOperand),
3918
+ leftOperand: parseDatetimeUTC(
3890
3919
  filter.leftOperand
3891
- ).getTime()
3920
+ )
3892
3921
  });
3893
3922
  } else {
3894
3923
  if (Array.isArray(filter.rightOperand)) {
3895
3924
  result.push({
3896
3925
  ...filter,
3897
3926
  rightOperand: filter.rightOperand.map(
3898
- (operand) => new Date(operand).getTime()
3927
+ (operand) => parseDatetimeUTC(operand)
3899
3928
  )
3900
3929
  });
3901
3930
  } else {
3902
3931
  result.push({
3903
3932
  ...filter,
3904
- rightOperand: new Date(filter.rightOperand).getTime()
3933
+ rightOperand: parseDatetimeUTC(filter.rightOperand)
3905
3934
  });
3906
3935
  }
3907
3936
  }
@@ -4046,13 +4075,11 @@ var makeFilter = ({
4046
4075
  } else if (dataType === "datetime") {
4047
4076
  operands = resolvedValues.map((resolvedValue) => {
4048
4077
  if (isList) {
4049
- return resolvedValue.map((listValue) => {
4050
- const coerced2 = new Date(listValue).getTime();
4051
- return isNaN(coerced2) ? Number(listValue) : coerced2;
4052
- });
4078
+ return resolvedValue.map(
4079
+ (listValue) => parseDatetimeUTC(listValue)
4080
+ );
4053
4081
  }
4054
- const coerced = new Date(resolvedValue).getTime();
4055
- return isNaN(coerced) ? Number(resolvedValue) : coerced;
4082
+ return parseDatetimeUTC(resolvedValue);
4056
4083
  });
4057
4084
  } else if (dataType === "boolean") {
4058
4085
  operands = resolvedValues.map((resolvedValue) => {
@@ -7308,7 +7335,8 @@ var Database = class {
7308
7335
  return {
7309
7336
  name: indexField.name,
7310
7337
  type: field?.type,
7311
- list: !!field?.list
7338
+ list: !!field?.list,
7339
+ pad: field?.type === "number" ? { fillString: "0", maxLength: DEFAULT_NUMERIC_LPAD } : void 0
7312
7340
  };
7313
7341
  })
7314
7342
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
3
  "type": "module",
4
- "version": "2.4.1",
4
+ "version": "2.4.3",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "files": [
@@ -43,8 +43,8 @@
43
43
  "normalize-path": "^3.0.0",
44
44
  "readable-stream": "^4.7.0",
45
45
  "yup": "^1.6.1",
46
- "@tinacms/mdx": "2.1.4",
47
- "@tinacms/schema-tools": "2.7.4"
46
+ "@tinacms/schema-tools": "2.8.1",
47
+ "@tinacms/mdx": "2.1.6"
48
48
  },
49
49
  "publishConfig": {
50
50
  "registry": "https://registry.npmjs.org"
@@ -72,7 +72,7 @@
72
72
  "vite": "^4.5.9",
73
73
  "vitest": "^0.32.4",
74
74
  "zod": "^3.24.2",
75
- "@tinacms/schema-tools": "2.7.4",
75
+ "@tinacms/schema-tools": "2.8.1",
76
76
  "@tinacms/scripts": "1.6.1"
77
77
  },
78
78
  "scripts": {