@postxl/schema 1.2.0 → 1.2.1

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.
@@ -4,6 +4,7 @@ export declare const standardFieldName_id: "id" & import("zod").$brand<"PXL.Fiel
4
4
  export declare const standardFieldName_createdAt: string & import("zod").$brand<"PXL.FieldName">;
5
5
  export declare const standardFieldName_updatedAt: string & import("zod").$brand<"PXL.FieldName">;
6
6
  export declare const standardFieldName_name: string & import("zod").$brand<"PXL.FieldName">;
7
+ export declare const standardFieldName_label: string & import("zod").$brand<"PXL.FieldName">;
7
8
  export declare const standardFieldNames: (string & import("zod").$brand<"PXL.FieldName">)[];
8
9
  export declare const standardField_id: FieldJSONInput;
9
10
  export declare const standardField_createdAt: FieldJSONInput;
@@ -33,12 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.standardFields = exports.standardField_name = exports.standardField_updatedAt = exports.standardField_createdAt = exports.standardField_id = exports.standardFieldNames = exports.standardFieldName_name = exports.standardFieldName_updatedAt = exports.standardFieldName_createdAt = exports.standardFieldName_id = void 0;
36
+ exports.standardFields = exports.standardField_name = exports.standardField_updatedAt = exports.standardField_createdAt = exports.standardField_id = exports.standardFieldNames = exports.standardFieldName_label = exports.standardFieldName_name = exports.standardFieldName_updatedAt = exports.standardFieldName_createdAt = exports.standardFieldName_id = void 0;
37
37
  const Branded = __importStar(require("./shared/brands"));
38
38
  exports.standardFieldName_id = Branded.toFieldIdName('id');
39
39
  exports.standardFieldName_createdAt = Branded.toFieldName('createdAt');
40
40
  exports.standardFieldName_updatedAt = Branded.toFieldName('updatedAt');
41
41
  exports.standardFieldName_name = Branded.toFieldName('name');
42
+ exports.standardFieldName_label = Branded.toFieldName('label');
42
43
  exports.standardFieldNames = [
43
44
  exports.standardFieldName_id,
44
45
  exports.standardFieldName_createdAt,
@@ -424,12 +424,14 @@ function extractLabelField({ labelFieldName, ...model }, fields, ctx) {
424
424
  return labelField;
425
425
  }
426
426
  function extractLabelFieldFromNameOrIdField({ name }, fields, ctx) {
427
- // If no label field is provided, ensure name field exists and use it
428
- const fallbackField = fields.get(Field.standardFieldName_name) ?? fields.get(Field.standardFieldName_id);
427
+ // If no label field is provided, try name field first, then label field, then id field
428
+ const fallbackField = fields.get(Field.standardFieldName_name) ??
429
+ fields.get(Field.standardFieldName_label) ??
430
+ fields.get(Field.standardFieldName_id);
429
431
  if (fallbackField === undefined) {
430
432
  ctx.addIssue({
431
433
  code: zod_1.z.ZodIssueCode.custom,
432
- message: `Model ${name} neither provides a \`${Field.standardFieldName_name}\` field nor has \`labelField\` property!`,
434
+ message: `Model ${name} neither provides a \`${Field.standardFieldName_name}\` or \`${Field.standardFieldName_label}\` field nor has \`labelField\` property!`,
433
435
  });
434
436
  return zod_1.z.NEVER;
435
437
  }
@@ -136,7 +136,7 @@
136
136
  ],
137
137
  "standardFields": ["id", "createdAt", "updatedAt"],
138
138
  "labelField": "title",
139
- "standardActions": ["create", "update", "upsert", "delete", "clone", "cloneMany"],
139
+ "standardActions": ["create", "update", "updateField", "upsert", "delete", "clone", "cloneMany"],
140
140
  "actions": {
141
141
  "publish": "Publish a post",
142
142
  "unpublish": "Unpublish a post"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/schema",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Decoders for PXL Schema definitions and validation for PXL code generation framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "directory": "packages/schema"
37
37
  },
38
38
  "dependencies": {
39
- "@postxl/utils": "^1.2.0"
39
+ "@postxl/utils": "^1.3.0"
40
40
  },
41
41
  "devDependencies": {},
42
42
  "wallaby": {