@smartive/graphql-magic 23.11.0 → 23.12.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
- ## [23.11.0](https://github.com/smartive/graphql-magic/compare/v23.10.0...v23.11.0) (2026-03-19)
1
+ ## [23.12.0-next.2](https://github.com/smartive/graphql-magic/compare/v23.12.0-next.1...v23.12.0-next.2) (2026-03-31)
2
2
 
3
3
  ### Features
4
4
 
5
- * Enable mutation args ([#442](https://github.com/smartive/graphql-magic/issues/442)) ([37a5e6e](https://github.com/smartive/graphql-magic/commit/37a5e6ebff67d7284015d9bb60695f2c107a6c88))
5
+ * enhance Time type handling with strict format and utility functions ([a682c86](https://github.com/smartive/graphql-magic/commit/a682c8674e71581844606d580a56a518231121ad))
package/dist/bin/gqm.cjs CHANGED
@@ -140,6 +140,10 @@ var Models = class {
140
140
  kind: "scalar",
141
141
  name: "DateTime"
142
142
  },
143
+ {
144
+ kind: "scalar",
145
+ name: "Time"
146
+ },
143
147
  { kind: "scalar", name: "Upload" },
144
148
  {
145
149
  kind: "raw-enum",
@@ -709,6 +713,10 @@ var generateDBModels = (models, dateLibrary) => {
709
713
  indentNumberOfSpaces: 2
710
714
  });
711
715
  writer.write(DATE_CLASS_IMPORT[dateLibrary]).blankLine();
716
+ writer.write(`type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';`);
717
+ writer.write(`type Hour = \`0\${Digit}\` | \`1\${Digit}\` | \`2\${'0' | '1' | '2' | '3'}\`;`);
718
+ writer.write(`type Minute = \`\${'0' | '1' | '2' | '3' | '4' | '5'}\${Digit}\`;`);
719
+ writer.write(`export type Time = \`\${Hour}:\${Minute}\`;`).blankLine();
712
720
  for (const [key, value2] of Object.entries(PRIMITIVE_TYPES)) {
713
721
  writer.write(`export type ${key} = ${value2};`).blankLine();
714
722
  }
@@ -790,6 +798,9 @@ var getFieldType = (field, dateLibrary, input2) => {
790
798
  if (field.type === "DateTime") {
791
799
  return (input2 ? `(${DATE_CLASS[dateLibrary]} | string)` : DATE_CLASS[dateLibrary]) + (field.list ? "[]" : "");
792
800
  }
801
+ if (field.type === "Time") {
802
+ return `Time${field.list ? "[]" : ""}`;
803
+ }
793
804
  return get(PRIMITIVE_TYPES, field.type) + (field.list ? "[]" : "");
794
805
  default: {
795
806
  const exhaustiveCheck = kind;
@@ -904,6 +915,9 @@ var getColumnName = (field) => field.kind === "relation" ? field.foreignKey || `
904
915
  var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
905
916
  var import_flatMap = __toESM(require("lodash/flatMap"), 1);
906
917
 
918
+ // src/resolvers/resolvers.ts
919
+ var import_graphql5 = require("graphql");
920
+
907
921
  // src/migrations/update-functions.ts
908
922
  var normalizeWhitespace = (str) => {
909
923
  return str.replace(/\s+/g, " ").replace(/\s*\(\s*/g, "(").replace(/\s*\)\s*/g, ")").replace(/\s*,\s*/g, ",").replace(/\s*;\s*/g, ";").trim();
@@ -2289,6 +2303,9 @@ var MigrationGenerator = class _MigrationGenerator {
2289
2303
  case "DateTime":
2290
2304
  col(`table.timestamp('${name2}')`);
2291
2305
  break;
2306
+ case "Time":
2307
+ col(`table.specificType('${name2}', 'time without time zone')`);
2308
+ break;
2292
2309
  case "ID":
2293
2310
  col(`table.uuid('${name2}')`);
2294
2311
  break;
@@ -2381,6 +2398,11 @@ var MigrationGenerator = class _MigrationGenerator {
2381
2398
  return true;
2382
2399
  }
2383
2400
  }
2401
+ if (field.type === "Time") {
2402
+ if (!["time without time zone", "time"].includes(col.data_type)) {
2403
+ return true;
2404
+ }
2405
+ }
2384
2406
  }
2385
2407
  return false;
2386
2408
  }
@@ -2470,48 +2492,48 @@ var getMigrationDate = () => {
2470
2492
  var ACTIONS = ["READ", "CREATE", "UPDATE", "DELETE", "RESTORE", "LINK"];
2471
2493
 
2472
2494
  // src/schema/generate.ts
2473
- var import_graphql6 = require("graphql");
2495
+ var import_graphql7 = require("graphql");
2474
2496
 
2475
2497
  // src/schema/utils.ts
2476
2498
  var import_dayjs2 = require("dayjs");
2477
- var import_graphql5 = require("graphql");
2499
+ var import_graphql6 = require("graphql");
2478
2500
  var import_luxon2 = require("luxon");
2479
2501
  var document = (definitions) => ({
2480
- kind: import_graphql5.Kind.DOCUMENT,
2502
+ kind: import_graphql6.Kind.DOCUMENT,
2481
2503
  definitions
2482
2504
  });
2483
2505
  var scalar = (nme) => ({
2484
2506
  name: name(nme),
2485
- kind: import_graphql5.Kind.SCALAR_TYPE_DEFINITION
2507
+ kind: import_graphql6.Kind.SCALAR_TYPE_DEFINITION
2486
2508
  });
2487
2509
  var input = (nme, fields2, dvs) => ({
2488
2510
  name: name(nme),
2489
2511
  fields: inputValues(fields2),
2490
- kind: import_graphql5.Kind.INPUT_OBJECT_TYPE_DEFINITION,
2512
+ kind: import_graphql6.Kind.INPUT_OBJECT_TYPE_DEFINITION,
2491
2513
  directives: directives(dvs)
2492
2514
  });
2493
2515
  var union = (nme, types) => ({
2494
2516
  name: name(nme),
2495
- kind: import_graphql5.Kind.UNION_TYPE_DEFINITION,
2517
+ kind: import_graphql6.Kind.UNION_TYPE_DEFINITION,
2496
2518
  types: types.map((t) => namedType(t))
2497
2519
  });
2498
2520
  var object = (nme, fds, interfaces, dvs) => ({
2499
2521
  name: name(nme),
2500
2522
  fields: fields(fds),
2501
- kind: import_graphql5.Kind.OBJECT_TYPE_DEFINITION,
2523
+ kind: import_graphql6.Kind.OBJECT_TYPE_DEFINITION,
2502
2524
  interfaces: interfaces?.map((i) => namedType(i)),
2503
2525
  directives: directives(dvs)
2504
2526
  });
2505
2527
  var iface = (nme, fds, interfaces, dvs) => ({
2506
2528
  name: name(nme),
2507
2529
  fields: fields(fds),
2508
- kind: import_graphql5.Kind.INTERFACE_TYPE_DEFINITION,
2530
+ kind: import_graphql6.Kind.INTERFACE_TYPE_DEFINITION,
2509
2531
  interfaces: interfaces?.map((i) => namedType(i)),
2510
2532
  directives: directives(dvs)
2511
2533
  });
2512
2534
  var inputValues = (fields2) => fields2.map(
2513
2535
  (field) => ({
2514
- kind: import_graphql5.Kind.INPUT_VALUE_DEFINITION,
2536
+ kind: import_graphql6.Kind.INPUT_VALUE_DEFINITION,
2515
2537
  name: name(field.name),
2516
2538
  type: fieldType(field),
2517
2539
  defaultValue: field.defaultValue === void 0 ? void 0 : value(field.defaultValue),
@@ -2520,11 +2542,11 @@ var inputValues = (fields2) => fields2.map(
2520
2542
  );
2521
2543
  var fields = (fields2) => fields2.map(
2522
2544
  (field) => ({
2523
- kind: import_graphql5.Kind.FIELD_DEFINITION,
2545
+ kind: import_graphql6.Kind.FIELD_DEFINITION,
2524
2546
  name: name(field.name),
2525
2547
  type: fieldType(field),
2526
2548
  arguments: field.args?.map((arg) => ({
2527
- kind: import_graphql5.Kind.INPUT_VALUE_DEFINITION,
2549
+ kind: import_graphql6.Kind.INPUT_VALUE_DEFINITION,
2528
2550
  name: name(arg.name),
2529
2551
  type: fieldType(arg),
2530
2552
  defaultValue: arg.defaultValue === void 0 ? void 0 : value(arg.defaultValue)
@@ -2534,42 +2556,42 @@ var fields = (fields2) => fields2.map(
2534
2556
  );
2535
2557
  var directives = (directives2) => directives2?.map(
2536
2558
  (directive) => ({
2537
- kind: import_graphql5.Kind.DIRECTIVE,
2559
+ kind: import_graphql6.Kind.DIRECTIVE,
2538
2560
  name: name(directive.name),
2539
2561
  arguments: args(directive.values)
2540
2562
  })
2541
2563
  );
2542
2564
  var args = (ags) => ags?.map(
2543
2565
  (argument) => ({
2544
- kind: import_graphql5.Kind.ARGUMENT,
2566
+ kind: import_graphql6.Kind.ARGUMENT,
2545
2567
  name: name(argument.name),
2546
2568
  value: value(argument.values)
2547
2569
  })
2548
2570
  );
2549
2571
  var enm = (nme, values) => ({
2550
2572
  name: name(nme),
2551
- kind: import_graphql5.Kind.ENUM_TYPE_DEFINITION,
2573
+ kind: import_graphql6.Kind.ENUM_TYPE_DEFINITION,
2552
2574
  values: values.map(
2553
2575
  (v) => ({
2554
- kind: import_graphql5.Kind.ENUM_VALUE_DEFINITION,
2576
+ kind: import_graphql6.Kind.ENUM_VALUE_DEFINITION,
2555
2577
  name: name(v)
2556
2578
  })
2557
2579
  )
2558
2580
  });
2559
2581
  var nonNull = (type) => ({
2560
2582
  type,
2561
- kind: import_graphql5.Kind.NON_NULL_TYPE
2583
+ kind: import_graphql6.Kind.NON_NULL_TYPE
2562
2584
  });
2563
2585
  var namedType = (nme) => ({
2564
- kind: import_graphql5.Kind.NAMED_TYPE,
2586
+ kind: import_graphql6.Kind.NAMED_TYPE,
2565
2587
  name: name(nme)
2566
2588
  });
2567
2589
  var list = (type) => ({
2568
2590
  type,
2569
- kind: import_graphql5.Kind.LIST_TYPE
2591
+ kind: import_graphql6.Kind.LIST_TYPE
2570
2592
  });
2571
2593
  var name = (name2) => ({
2572
- kind: import_graphql5.Kind.NAME,
2594
+ kind: import_graphql6.Kind.NAME,
2573
2595
  value: name2
2574
2596
  });
2575
2597
  var fieldType = (field) => {
@@ -2583,33 +2605,33 @@ var fieldType = (field) => {
2583
2605
  return type;
2584
2606
  };
2585
2607
  var value = (val = null) => val === null ? {
2586
- kind: import_graphql5.Kind.NULL
2608
+ kind: import_graphql6.Kind.NULL
2587
2609
  } : typeof val === "boolean" ? {
2588
- kind: import_graphql5.Kind.BOOLEAN,
2610
+ kind: import_graphql6.Kind.BOOLEAN,
2589
2611
  value: val
2590
2612
  } : typeof val === "number" ? {
2591
- kind: import_graphql5.Kind.INT,
2613
+ kind: import_graphql6.Kind.INT,
2592
2614
  value: `${val}`
2593
2615
  } : typeof val === "string" ? {
2594
- kind: import_graphql5.Kind.STRING,
2616
+ kind: import_graphql6.Kind.STRING,
2595
2617
  value: val
2596
2618
  } : val instanceof Symbol ? {
2597
- kind: import_graphql5.Kind.ENUM,
2619
+ kind: import_graphql6.Kind.ENUM,
2598
2620
  value: val.description
2599
2621
  } : Array.isArray(val) ? {
2600
- kind: import_graphql5.Kind.LIST,
2622
+ kind: import_graphql6.Kind.LIST,
2601
2623
  values: val.map(value)
2602
2624
  } : val instanceof import_luxon2.DateTime ? {
2603
- kind: import_graphql5.Kind.STRING,
2625
+ kind: import_graphql6.Kind.STRING,
2604
2626
  value: val.toString()
2605
2627
  } : val instanceof import_dayjs2.Dayjs ? {
2606
- kind: import_graphql5.Kind.STRING,
2628
+ kind: import_graphql6.Kind.STRING,
2607
2629
  value: val.toISOString()
2608
2630
  } : typeof val === "object" ? {
2609
- kind: import_graphql5.Kind.OBJECT,
2631
+ kind: import_graphql6.Kind.OBJECT,
2610
2632
  fields: Object.keys(val).map(
2611
2633
  (nme) => ({
2612
- kind: import_graphql5.Kind.OBJECT_FIELD,
2634
+ kind: import_graphql6.Kind.OBJECT_FIELD,
2613
2635
  name: name(nme),
2614
2636
  value: value(val[nme])
2615
2637
  })
@@ -2889,11 +2911,11 @@ var generateDefinitions = ({
2889
2911
  };
2890
2912
  var generate = (models) => document(generateDefinitions(models));
2891
2913
  var printSchema = (schema) => [
2892
- ...schema.getDirectives().map((d) => d.astNode && (0, import_graphql6.print)(d.astNode)),
2893
- ...Object.values(schema.getTypeMap()).filter((t) => !t.name.match(/^__/)).sort((a, b) => a.name > b.name ? 1 : -1).map((t) => t.astNode && (0, import_graphql6.print)(t.astNode))
2914
+ ...schema.getDirectives().map((d) => d.astNode && (0, import_graphql7.print)(d.astNode)),
2915
+ ...Object.values(schema.getTypeMap()).filter((t) => !t.name.match(/^__/)).sort((a, b) => a.name > b.name ? 1 : -1).map((t) => t.astNode && (0, import_graphql7.print)(t.astNode))
2894
2916
  ].filter(Boolean).map((s) => `${s}
2895
2917
  `).join("\n");
2896
- var printSchemaFromModels = (models) => printSchema((0, import_graphql6.buildASTSchema)(generate(models)));
2918
+ var printSchemaFromModels = (models) => printSchema((0, import_graphql7.buildASTSchema)(generate(models)));
2897
2919
 
2898
2920
  // src/bin/gqm/codegen.ts
2899
2921
  var import_cli = require("@graphql-codegen/cli");
@@ -3196,12 +3218,18 @@ var generateGraphqlApiTypes = async (dateLibrary) => {
3196
3218
  documents: void 0,
3197
3219
  generates: {
3198
3220
  [`${generatedFolderPath}/api/index.ts`]: {
3199
- plugins: ["typescript", "typescript-resolvers", { add: { content: DATE_CLASS_IMPORT[dateLibrary] } }]
3221
+ plugins: [
3222
+ "typescript",
3223
+ "typescript-resolvers",
3224
+ { add: { content: DATE_CLASS_IMPORT[dateLibrary] } },
3225
+ { add: { content: `import type { Time } from '@smartive/graphql-magic';` } }
3226
+ ]
3200
3227
  }
3201
3228
  },
3202
3229
  config: {
3203
3230
  scalars: {
3204
- DateTime: DATE_CLASS[dateLibrary]
3231
+ DateTime: DATE_CLASS[dateLibrary],
3232
+ Time: "Time"
3205
3233
  }
3206
3234
  }
3207
3235
  });
@@ -3215,7 +3243,11 @@ var generateGraphqlClientTypes = async () => {
3215
3243
  documents: [graphqlQueriesPath, `${generatedFolderPath}/client/mutations.ts`],
3216
3244
  generates: {
3217
3245
  [`${generatedFolderPath}/client/index.ts`]: {
3218
- plugins: ["typescript", "typescript-operations"]
3246
+ plugins: [
3247
+ "typescript",
3248
+ "typescript-operations",
3249
+ { add: { content: `import type { Time } from '@smartive/graphql-magic';` } }
3250
+ ]
3219
3251
  }
3220
3252
  },
3221
3253
  config: {
@@ -3230,7 +3262,8 @@ var generateGraphqlClientTypes = async () => {
3230
3262
  field: true
3231
3263
  },
3232
3264
  scalars: {
3233
- DateTime: "string"
3265
+ DateTime: "string",
3266
+ Time: "Time"
3234
3267
  },
3235
3268
  ignoreNoDocuments: true
3236
3269
  }
@@ -180,6 +180,7 @@ __export(index_exports, {
180
180
  object: () => object,
181
181
  or: () => or,
182
182
  ors: () => ors,
183
+ parseTime: () => parseTime,
183
184
  printSchema: () => printSchema,
184
185
  printSchemaFromDocument: () => printSchemaFromDocument,
185
186
  printSchemaFromModels: () => printSchemaFromModels,
@@ -189,6 +190,7 @@ __export(index_exports, {
189
190
  restoreEntity: () => restoreEntity,
190
191
  retry: () => retry,
191
192
  scalar: () => scalar,
193
+ serializeTime: () => serializeTime,
192
194
  summon: () => summon,
193
195
  summonByKey: () => summonByKey,
194
196
  summonByName: () => summonByName,
@@ -406,6 +408,10 @@ var Models = class {
406
408
  kind: "scalar",
407
409
  name: "DateTime"
408
410
  },
411
+ {
412
+ kind: "scalar",
413
+ name: "Time"
414
+ },
409
415
  { kind: "scalar", name: "Upload" },
410
416
  {
411
417
  kind: "raw-enum",
@@ -1084,6 +1090,10 @@ var generateDBModels = (models, dateLibrary) => {
1084
1090
  indentNumberOfSpaces: 2
1085
1091
  });
1086
1092
  writer.write(DATE_CLASS_IMPORT[dateLibrary]).blankLine();
1093
+ writer.write(`type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';`);
1094
+ writer.write(`type Hour = \`0\${Digit}\` | \`1\${Digit}\` | \`2\${'0' | '1' | '2' | '3'}\`;`);
1095
+ writer.write(`type Minute = \`\${'0' | '1' | '2' | '3' | '4' | '5'}\${Digit}\`;`);
1096
+ writer.write(`export type Time = \`\${Hour}:\${Minute}\`;`).blankLine();
1087
1097
  for (const [key, value2] of Object.entries(PRIMITIVE_TYPES)) {
1088
1098
  writer.write(`export type ${key} = ${value2};`).blankLine();
1089
1099
  }
@@ -1165,6 +1175,9 @@ var getFieldType = (field, dateLibrary, input2) => {
1165
1175
  if (field.type === "DateTime") {
1166
1176
  return (input2 ? `(${DATE_CLASS[dateLibrary]} | string)` : DATE_CLASS[dateLibrary]) + (field.list ? "[]" : "");
1167
1177
  }
1178
+ if (field.type === "Time") {
1179
+ return `Time${field.list ? "[]" : ""}`;
1180
+ }
1168
1181
  return get(PRIMITIVE_TYPES, field.type) + (field.list ? "[]" : "");
1169
1182
  default: {
1170
1183
  const exhaustiveCheck = kind;
@@ -2011,6 +2024,30 @@ var applyWhere2 = (model, query, alias, where, aliases) => {
2011
2024
  }
2012
2025
  };
2013
2026
 
2027
+ // src/utils/time.ts
2028
+ var PARSE_TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
2029
+ var SERIALIZE_TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d(?:\.\d+)?)?$/;
2030
+ var parseTime = (value2) => {
2031
+ if (typeof value2 !== "string") {
2032
+ throw new Error(`Time must be a string in HH:mm format. Received: ${typeof value2}`);
2033
+ }
2034
+ const match = value2.match(PARSE_TIME_RE);
2035
+ if (!match) {
2036
+ throw new Error(`Invalid Time value "${value2}". Expected HH:mm in 24-hour format.`);
2037
+ }
2038
+ return `${match[1]}:${match[2]}`;
2039
+ };
2040
+ var serializeTime = (value2) => {
2041
+ if (typeof value2 !== "string") {
2042
+ throw new Error(`Time must be a string in HH:mm format. Received: ${typeof value2}`);
2043
+ }
2044
+ const match = value2.match(SERIALIZE_TIME_RE);
2045
+ if (!match) {
2046
+ throw new Error(`Invalid Time value "${value2}". Expected HH:mm or HH:mm:ss.`);
2047
+ }
2048
+ return `${match[1]}:${match[2]}`;
2049
+ };
2050
+
2014
2051
  // src/resolvers/resolver.ts
2015
2052
  var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
2016
2053
  var import_flatMap = __toESM(require("lodash/flatMap"), 1);
@@ -2892,6 +2929,7 @@ var doUpdate = async (model, currentEntity, update, ctx) => {
2892
2929
  };
2893
2930
 
2894
2931
  // src/resolvers/resolvers.ts
2932
+ var import_graphql5 = require("graphql");
2895
2933
  var getResolvers = (models) => {
2896
2934
  const resolvers = {
2897
2935
  Query: merge2([
@@ -2907,7 +2945,19 @@ var getResolvers = (models) => {
2907
2945
  ...models.entities.filter(({ aggregatable }) => aggregatable).map((model) => ({
2908
2946
  [`${model.pluralField}_AGGREGATE`]: queryResolver
2909
2947
  }))
2910
- ])
2948
+ ]),
2949
+ Time: new import_graphql5.GraphQLScalarType({
2950
+ name: "Time",
2951
+ description: "Time without date and timezone (HH:mm)",
2952
+ serialize: (value2) => value2 == null ? value2 : serializeTime(value2),
2953
+ parseValue: (value2) => parseTime(value2),
2954
+ parseLiteral: (ast) => {
2955
+ if (ast.kind !== import_graphql5.Kind.STRING) {
2956
+ throw new Error(`Invalid literal for Time scalar. Expected STRING, got ${ast.kind}.`);
2957
+ }
2958
+ return parseTime(ast.value);
2959
+ }
2960
+ })
2911
2961
  };
2912
2962
  const mutations = [
2913
2963
  ...models.entities.filter(and(not(isRootModel), isCreatable)).map((model) => ({
@@ -4317,6 +4367,9 @@ var MigrationGenerator = class _MigrationGenerator {
4317
4367
  case "DateTime":
4318
4368
  col(`table.timestamp('${name2}')`);
4319
4369
  break;
4370
+ case "Time":
4371
+ col(`table.specificType('${name2}', 'time without time zone')`);
4372
+ break;
4320
4373
  case "ID":
4321
4374
  col(`table.uuid('${name2}')`);
4322
4375
  break;
@@ -4409,6 +4462,11 @@ var MigrationGenerator = class _MigrationGenerator {
4409
4462
  return true;
4410
4463
  }
4411
4464
  }
4465
+ if (field.type === "Time") {
4466
+ if (!["time without time zone", "time"].includes(col.data_type)) {
4467
+ return true;
4468
+ }
4469
+ }
4412
4470
  }
4413
4471
  return false;
4414
4472
  }
@@ -4576,55 +4634,55 @@ var addPermissions = (models, permissions, links, block) => {
4576
4634
  };
4577
4635
 
4578
4636
  // src/schema/generate.ts
4579
- var import_graphql6 = require("graphql");
4637
+ var import_graphql7 = require("graphql");
4580
4638
 
4581
4639
  // src/schema/utils.ts
4582
4640
  var import_dayjs2 = require("dayjs");
4583
- var import_graphql5 = require("graphql");
4641
+ var import_graphql6 = require("graphql");
4584
4642
  var import_luxon2 = require("luxon");
4585
4643
  var document = (definitions) => ({
4586
- kind: import_graphql5.Kind.DOCUMENT,
4644
+ kind: import_graphql6.Kind.DOCUMENT,
4587
4645
  definitions
4588
4646
  });
4589
4647
  var directive = (nme, locations, fields2) => ({
4590
4648
  name: name(nme),
4591
4649
  repeatable: false,
4592
- kind: import_graphql5.Kind.DIRECTIVE_DEFINITION,
4650
+ kind: import_graphql6.Kind.DIRECTIVE_DEFINITION,
4593
4651
  arguments: fields2 && inputValues(fields2),
4594
4652
  locations: locations.map(name)
4595
4653
  });
4596
4654
  var scalar = (nme) => ({
4597
4655
  name: name(nme),
4598
- kind: import_graphql5.Kind.SCALAR_TYPE_DEFINITION
4656
+ kind: import_graphql6.Kind.SCALAR_TYPE_DEFINITION
4599
4657
  });
4600
4658
  var input = (nme, fields2, dvs) => ({
4601
4659
  name: name(nme),
4602
4660
  fields: inputValues(fields2),
4603
- kind: import_graphql5.Kind.INPUT_OBJECT_TYPE_DEFINITION,
4661
+ kind: import_graphql6.Kind.INPUT_OBJECT_TYPE_DEFINITION,
4604
4662
  directives: directives(dvs)
4605
4663
  });
4606
4664
  var union = (nme, types) => ({
4607
4665
  name: name(nme),
4608
- kind: import_graphql5.Kind.UNION_TYPE_DEFINITION,
4666
+ kind: import_graphql6.Kind.UNION_TYPE_DEFINITION,
4609
4667
  types: types.map((t) => namedType(t))
4610
4668
  });
4611
4669
  var object = (nme, fds, interfaces, dvs) => ({
4612
4670
  name: name(nme),
4613
4671
  fields: fields(fds),
4614
- kind: import_graphql5.Kind.OBJECT_TYPE_DEFINITION,
4672
+ kind: import_graphql6.Kind.OBJECT_TYPE_DEFINITION,
4615
4673
  interfaces: interfaces?.map((i) => namedType(i)),
4616
4674
  directives: directives(dvs)
4617
4675
  });
4618
4676
  var iface = (nme, fds, interfaces, dvs) => ({
4619
4677
  name: name(nme),
4620
4678
  fields: fields(fds),
4621
- kind: import_graphql5.Kind.INTERFACE_TYPE_DEFINITION,
4679
+ kind: import_graphql6.Kind.INTERFACE_TYPE_DEFINITION,
4622
4680
  interfaces: interfaces?.map((i) => namedType(i)),
4623
4681
  directives: directives(dvs)
4624
4682
  });
4625
4683
  var inputValues = (fields2) => fields2.map(
4626
4684
  (field) => ({
4627
- kind: import_graphql5.Kind.INPUT_VALUE_DEFINITION,
4685
+ kind: import_graphql6.Kind.INPUT_VALUE_DEFINITION,
4628
4686
  name: name(field.name),
4629
4687
  type: fieldType(field),
4630
4688
  defaultValue: field.defaultValue === void 0 ? void 0 : value(field.defaultValue),
@@ -4633,11 +4691,11 @@ var inputValues = (fields2) => fields2.map(
4633
4691
  );
4634
4692
  var fields = (fields2) => fields2.map(
4635
4693
  (field) => ({
4636
- kind: import_graphql5.Kind.FIELD_DEFINITION,
4694
+ kind: import_graphql6.Kind.FIELD_DEFINITION,
4637
4695
  name: name(field.name),
4638
4696
  type: fieldType(field),
4639
4697
  arguments: field.args?.map((arg) => ({
4640
- kind: import_graphql5.Kind.INPUT_VALUE_DEFINITION,
4698
+ kind: import_graphql6.Kind.INPUT_VALUE_DEFINITION,
4641
4699
  name: name(arg.name),
4642
4700
  type: fieldType(arg),
4643
4701
  defaultValue: arg.defaultValue === void 0 ? void 0 : value(arg.defaultValue)
@@ -4648,49 +4706,49 @@ var fields = (fields2) => fields2.map(
4648
4706
  var inputValue = (nme, type, dvs, description, defaultValue) => ({
4649
4707
  name: name(nme),
4650
4708
  type,
4651
- kind: import_graphql5.Kind.INPUT_VALUE_DEFINITION,
4709
+ kind: import_graphql6.Kind.INPUT_VALUE_DEFINITION,
4652
4710
  directives: directives(dvs),
4653
4711
  defaultValue: defaultValue ? value(defaultValue) : void 0,
4654
4712
  description: description ? value(description) : void 0
4655
4713
  });
4656
4714
  var directives = (directives2) => directives2?.map(
4657
4715
  (directive2) => ({
4658
- kind: import_graphql5.Kind.DIRECTIVE,
4716
+ kind: import_graphql6.Kind.DIRECTIVE,
4659
4717
  name: name(directive2.name),
4660
4718
  arguments: args(directive2.values)
4661
4719
  })
4662
4720
  );
4663
4721
  var args = (ags) => ags?.map(
4664
4722
  (argument) => ({
4665
- kind: import_graphql5.Kind.ARGUMENT,
4723
+ kind: import_graphql6.Kind.ARGUMENT,
4666
4724
  name: name(argument.name),
4667
4725
  value: value(argument.values)
4668
4726
  })
4669
4727
  );
4670
4728
  var enm = (nme, values) => ({
4671
4729
  name: name(nme),
4672
- kind: import_graphql5.Kind.ENUM_TYPE_DEFINITION,
4730
+ kind: import_graphql6.Kind.ENUM_TYPE_DEFINITION,
4673
4731
  values: values.map(
4674
4732
  (v) => ({
4675
- kind: import_graphql5.Kind.ENUM_VALUE_DEFINITION,
4733
+ kind: import_graphql6.Kind.ENUM_VALUE_DEFINITION,
4676
4734
  name: name(v)
4677
4735
  })
4678
4736
  )
4679
4737
  });
4680
4738
  var nonNull = (type) => ({
4681
4739
  type,
4682
- kind: import_graphql5.Kind.NON_NULL_TYPE
4740
+ kind: import_graphql6.Kind.NON_NULL_TYPE
4683
4741
  });
4684
4742
  var namedType = (nme) => ({
4685
- kind: import_graphql5.Kind.NAMED_TYPE,
4743
+ kind: import_graphql6.Kind.NAMED_TYPE,
4686
4744
  name: name(nme)
4687
4745
  });
4688
4746
  var list = (type) => ({
4689
4747
  type,
4690
- kind: import_graphql5.Kind.LIST_TYPE
4748
+ kind: import_graphql6.Kind.LIST_TYPE
4691
4749
  });
4692
4750
  var name = (name2) => ({
4693
- kind: import_graphql5.Kind.NAME,
4751
+ kind: import_graphql6.Kind.NAME,
4694
4752
  value: name2
4695
4753
  });
4696
4754
  var fieldType = (field) => {
@@ -4704,33 +4762,33 @@ var fieldType = (field) => {
4704
4762
  return type;
4705
4763
  };
4706
4764
  var value = (val = null) => val === null ? {
4707
- kind: import_graphql5.Kind.NULL
4765
+ kind: import_graphql6.Kind.NULL
4708
4766
  } : typeof val === "boolean" ? {
4709
- kind: import_graphql5.Kind.BOOLEAN,
4767
+ kind: import_graphql6.Kind.BOOLEAN,
4710
4768
  value: val
4711
4769
  } : typeof val === "number" ? {
4712
- kind: import_graphql5.Kind.INT,
4770
+ kind: import_graphql6.Kind.INT,
4713
4771
  value: `${val}`
4714
4772
  } : typeof val === "string" ? {
4715
- kind: import_graphql5.Kind.STRING,
4773
+ kind: import_graphql6.Kind.STRING,
4716
4774
  value: val
4717
4775
  } : val instanceof Symbol ? {
4718
- kind: import_graphql5.Kind.ENUM,
4776
+ kind: import_graphql6.Kind.ENUM,
4719
4777
  value: val.description
4720
4778
  } : Array.isArray(val) ? {
4721
- kind: import_graphql5.Kind.LIST,
4779
+ kind: import_graphql6.Kind.LIST,
4722
4780
  values: val.map(value)
4723
4781
  } : val instanceof import_luxon2.DateTime ? {
4724
- kind: import_graphql5.Kind.STRING,
4782
+ kind: import_graphql6.Kind.STRING,
4725
4783
  value: val.toString()
4726
4784
  } : val instanceof import_dayjs2.Dayjs ? {
4727
- kind: import_graphql5.Kind.STRING,
4785
+ kind: import_graphql6.Kind.STRING,
4728
4786
  value: val.toISOString()
4729
4787
  } : typeof val === "object" ? {
4730
- kind: import_graphql5.Kind.OBJECT,
4788
+ kind: import_graphql6.Kind.OBJECT,
4731
4789
  fields: Object.keys(val).map(
4732
4790
  (nme) => ({
4733
- kind: import_graphql5.Kind.OBJECT_FIELD,
4791
+ kind: import_graphql6.Kind.OBJECT_FIELD,
4734
4792
  name: name(nme),
4735
4793
  value: value(val[nme])
4736
4794
  })
@@ -5010,12 +5068,12 @@ var generateDefinitions = ({
5010
5068
  };
5011
5069
  var generate = (models) => document(generateDefinitions(models));
5012
5070
  var printSchema = (schema) => [
5013
- ...schema.getDirectives().map((d) => d.astNode && (0, import_graphql6.print)(d.astNode)),
5014
- ...Object.values(schema.getTypeMap()).filter((t) => !t.name.match(/^__/)).sort((a, b) => a.name > b.name ? 1 : -1).map((t) => t.astNode && (0, import_graphql6.print)(t.astNode))
5071
+ ...schema.getDirectives().map((d) => d.astNode && (0, import_graphql7.print)(d.astNode)),
5072
+ ...Object.values(schema.getTypeMap()).filter((t) => !t.name.match(/^__/)).sort((a, b) => a.name > b.name ? 1 : -1).map((t) => t.astNode && (0, import_graphql7.print)(t.astNode))
5015
5073
  ].filter(Boolean).map((s) => `${s}
5016
5074
  `).join("\n");
5017
- var printSchemaFromDocument = (document2) => printSchema((0, import_graphql6.buildASTSchema)(document2));
5018
- var printSchemaFromModels = (models) => printSchema((0, import_graphql6.buildASTSchema)(generate(models)));
5075
+ var printSchemaFromDocument = (document2) => printSchema((0, import_graphql7.buildASTSchema)(document2));
5076
+ var printSchemaFromModels = (models) => printSchema((0, import_graphql7.buildASTSchema)(generate(models)));
5019
5077
  // Annotate the CommonJS export names for ESM import in node:
5020
5078
  0 && (module.exports = {
5021
5079
  ACTIONS,
@@ -5169,6 +5227,7 @@ var printSchemaFromModels = (models) => printSchema((0, import_graphql6.buildAST
5169
5227
  object,
5170
5228
  or,
5171
5229
  ors,
5230
+ parseTime,
5172
5231
  printSchema,
5173
5232
  printSchemaFromDocument,
5174
5233
  printSchemaFromModels,
@@ -5178,6 +5237,7 @@ var printSchemaFromModels = (models) => printSchema((0, import_graphql6.buildAST
5178
5237
  restoreEntity,
5179
5238
  retry,
5180
5239
  scalar,
5240
+ serializeTime,
5181
5241
  summon,
5182
5242
  summonByKey,
5183
5243
  summonByName,
@@ -17,6 +17,10 @@ export const generateDBModels = (models, dateLibrary) => {
17
17
  indentNumberOfSpaces: 2,
18
18
  });
19
19
  writer.write(DATE_CLASS_IMPORT[dateLibrary]).blankLine();
20
+ writer.write(`type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';`);
21
+ writer.write(`type Hour = \`0\${Digit}\` | \`1\${Digit}\` | \`2\${'0' | '1' | '2' | '3'}\`;`);
22
+ writer.write(`type Minute = \`\${'0' | '1' | '2' | '3' | '4' | '5'}\${Digit}\`;`);
23
+ writer.write(`export type Time = \`\${Hour}:\${Minute}\`;`).blankLine();
20
24
  for (const [key, value] of Object.entries(PRIMITIVE_TYPES)) {
21
25
  writer.write(`export type ${key} = ${value};`).blankLine();
22
26
  }
@@ -117,6 +121,9 @@ const getFieldType = (field, dateLibrary, input) => {
117
121
  if (field.type === 'DateTime') {
118
122
  return (input ? `(${DATE_CLASS[dateLibrary]} | string)` : DATE_CLASS[dateLibrary]) + (field.list ? '[]' : '');
119
123
  }
124
+ if (field.type === 'Time') {
125
+ return `Time${field.list ? '[]' : ''}`;
126
+ }
120
127
  return get(PRIMITIVE_TYPES, field.type) + (field.list ? '[]' : '');
121
128
  default: {
122
129
  const exhaustiveCheck = kind;