@postxl/schema 1.3.1 → 1.4.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.
@@ -128,7 +128,7 @@ const fieldDiscriminatedUnionTransformer = ({ fieldInput, model, projectSchema }
128
128
  }
129
129
  const decodedField = decodedFieldResult.data;
130
130
  const transformedField = Fields.fieldTransformer(decodedField, model, projectSchema, ctx);
131
- commonFields.set(transformedField.name, addDiscriminatedUnionParent(transformedField, fieldInput.name));
131
+ commonFields.set(transformedField.name, addDiscriminatedUnionParent(transformedField, fieldInput.name, fieldInput.excelName));
132
132
  }
133
133
  const members = new Map();
134
134
  for (const memberInput of fieldInput.members) {
@@ -153,7 +153,7 @@ const fieldDiscriminatedUnionTransformer = ({ fieldInput, model, projectSchema }
153
153
  return zod_1.z.NEVER;
154
154
  }
155
155
  const transformedField = Fields.fieldTransformer(decodedField, model, projectSchema, ctx);
156
- memberFields.set(transformedField.name, addDiscriminatedUnionParentMember(transformedField, fieldInput.name, discriminator));
156
+ memberFields.set(transformedField.name, addDiscriminatedUnionParentMember(transformedField, fieldInput.name, fieldInput.excelName, discriminator));
157
157
  }
158
158
  members.set(discriminator, {
159
159
  type: discriminator,
@@ -174,7 +174,7 @@ const fieldDiscriminatedUnionTransformer = ({ fieldInput, model, projectSchema }
174
174
  return result;
175
175
  };
176
176
  exports.fieldDiscriminatedUnionTransformer = fieldDiscriminatedUnionTransformer;
177
- function addDiscriminatedUnionParent(field, duFieldName) {
177
+ function addDiscriminatedUnionParent(field, duFieldName, duExcelName) {
178
178
  const result = {
179
179
  ...field,
180
180
  discriminatedUnionFieldName: duFieldName,
@@ -183,10 +183,16 @@ function addDiscriminatedUnionParent(field, duFieldName) {
183
183
  databaseName: field.databaseName,
184
184
  newName: `${duFieldName}${(0, utils_1.toPascalCase)(field.name)}`,
185
185
  }),
186
+ excelName: ensureCustomExcelName({
187
+ name: field.name,
188
+ label: field.label,
189
+ excelName: field.excelName,
190
+ newName: `${duExcelName} ${field.excelName}`,
191
+ }),
186
192
  };
187
193
  return result;
188
194
  }
189
- function addDiscriminatedUnionParentMember(field, duFieldName, duMemberType) {
195
+ function addDiscriminatedUnionParentMember(field, duFieldName, duExcelName, duMemberType) {
190
196
  const result = {
191
197
  ...field,
192
198
  discriminatedUnionFieldName: duFieldName,
@@ -196,9 +202,22 @@ function addDiscriminatedUnionParentMember(field, duFieldName, duMemberType) {
196
202
  databaseName: field.databaseName,
197
203
  newName: `${duFieldName}${(0, utils_1.toPascalCase)(duMemberType)}${(0, utils_1.toPascalCase)(field.name)}`,
198
204
  }),
205
+ excelName: ensureCustomExcelName({
206
+ name: field.name,
207
+ label: field.label,
208
+ excelName: field.excelName,
209
+ newName: `${duExcelName} ${(0, utils_1.toPascalCase)(duMemberType)} ${field.excelName}`,
210
+ }),
199
211
  };
200
212
  return result;
201
213
  }
214
+ function ensureCustomExcelName({ excelName, name, label, newName, }) {
215
+ // If the user explicitly set a custom excelName (different from the defaults), keep it
216
+ if (excelName !== name && excelName !== label && excelName !== (0, utils_1.toHumanReadable)(name)) {
217
+ return excelName;
218
+ }
219
+ return Branded.toExcelColumnName(newName);
220
+ }
202
221
  function ensureCustomDatabaseName({ databaseName, name, newName, }) {
203
222
  if (databaseName !== name && databaseName !== (0, utils_1.toSnakeCase)(name)) {
204
223
  return databaseName;
@@ -5,12 +5,16 @@ export declare const standardModelName_User: string & import("zod").$brand<"PXL.
5
5
  export declare const standardModelName_Action: string & import("zod").$brand<"PXL.ModelName">;
6
6
  export declare const standardModelName_ActionOperation: string & import("zod").$brand<"PXL.ModelName">;
7
7
  export declare const standardModelName_File: string & import("zod").$brand<"PXL.ModelName">;
8
+ export declare const standardModelName_TableView: string & import("zod").$brand<"PXL.ModelName">;
9
+ export declare const standardModelName_Comment: string & import("zod").$brand<"PXL.ModelName">;
8
10
  export declare const defaultModelNames: {
9
11
  config: string & import("zod").$brand<"PXL.ModelName">;
10
12
  user: string & import("zod").$brand<"PXL.ModelName">;
11
13
  action: string & import("zod").$brand<"PXL.ModelName">;
12
14
  mutation: string & import("zod").$brand<"PXL.ModelName">;
13
15
  file: string & import("zod").$brand<"PXL.ModelName">;
16
+ tableView: string & import("zod").$brand<"PXL.ModelName">;
17
+ comment: string & import("zod").$brand<"PXL.ModelName">;
14
18
  };
15
19
  export declare const defaultModel_Config: ModelJSON;
16
20
  export declare const defaultModelJson_User: ModelJSON;
@@ -25,4 +29,6 @@ export declare const defaultModelJson_ActionOperation: ModelJSON & {
25
29
  };
26
30
  };
27
31
  export declare const defaultModelJson_File: ModelJSON;
32
+ export declare const defaultModelJson_TableView: ModelJSON;
33
+ export declare const defaultModelJson_Comment: ModelJSON;
28
34
  export declare const defaultModelsJson: Record<Branded.ModelName, ModelJSON>;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.defaultModelsJson = exports.defaultModelJson_File = exports.defaultModelJson_ActionOperation = exports.defaultModelJson_Action = exports.defaultModelJson_User = exports.defaultModel_Config = exports.defaultModelNames = exports.standardModelName_File = exports.standardModelName_ActionOperation = exports.standardModelName_Action = exports.standardModelName_User = exports.defaultModelName_Config = void 0;
36
+ exports.defaultModelsJson = exports.defaultModelJson_Comment = exports.defaultModelJson_TableView = exports.defaultModelJson_File = exports.defaultModelJson_ActionOperation = exports.defaultModelJson_Action = exports.defaultModelJson_User = exports.defaultModel_Config = exports.defaultModelNames = exports.standardModelName_Comment = exports.standardModelName_TableView = exports.standardModelName_File = exports.standardModelName_ActionOperation = exports.standardModelName_Action = exports.standardModelName_User = exports.defaultModelName_Config = void 0;
37
37
  const defaults_1 = require("../field/defaults");
38
38
  const project_schema_defaults_1 = require("../project-schema/project-schema.defaults");
39
39
  const Branded = __importStar(require("./model.brands"));
@@ -42,12 +42,16 @@ exports.standardModelName_User = Branded.toModelName('User');
42
42
  exports.standardModelName_Action = Branded.toModelName('Action');
43
43
  exports.standardModelName_ActionOperation = Branded.toModelName('ActionOperation');
44
44
  exports.standardModelName_File = Branded.toModelName('File');
45
+ exports.standardModelName_TableView = Branded.toModelName('TableView');
46
+ exports.standardModelName_Comment = Branded.toModelName('Comment');
45
47
  exports.defaultModelNames = {
46
48
  config: exports.defaultModelName_Config,
47
49
  user: exports.standardModelName_User,
48
50
  action: exports.standardModelName_Action,
49
51
  mutation: exports.standardModelName_ActionOperation,
50
52
  file: exports.standardModelName_File,
53
+ tableView: exports.standardModelName_TableView,
54
+ comment: exports.standardModelName_Comment,
51
55
  };
52
56
  exports.defaultModel_Config = {
53
57
  name: exports.defaultModelName_Config,
@@ -295,10 +299,111 @@ exports.defaultModelJson_File = {
295
299
  ],
296
300
  faker: { items: 0 },
297
301
  };
302
+ exports.defaultModelJson_TableView = {
303
+ name: exports.standardModelName_TableView,
304
+ description: 'A persisted table view configuration, storing filters, sorting, column visibility, and column order.',
305
+ schema: project_schema_defaults_1.databaseSchemaNameConfig,
306
+ fields: [
307
+ {
308
+ name: 'name',
309
+ type: 'String',
310
+ label: 'Name',
311
+ description: 'The name of the view.',
312
+ },
313
+ {
314
+ name: 'model',
315
+ type: 'String',
316
+ description: 'The model/table this view applies to.',
317
+ },
318
+ {
319
+ name: 'userId',
320
+ type: 'User',
321
+ description: 'The user that created this view.',
322
+ },
323
+ {
324
+ name: 'isGlobal',
325
+ type: 'Boolean',
326
+ description: 'Whether this view is visible to all users.',
327
+ },
328
+ {
329
+ name: 'filters',
330
+ type: 'String?',
331
+ description: 'JSON string containing the filter configuration.',
332
+ },
333
+ {
334
+ name: 'sorting',
335
+ type: 'String?',
336
+ description: 'JSON string containing the sorting configuration.',
337
+ },
338
+ {
339
+ name: 'columnVisibility',
340
+ type: 'String?',
341
+ description: 'JSON string containing column visibility state.',
342
+ },
343
+ {
344
+ name: 'columnOrder',
345
+ type: 'String?',
346
+ description: 'JSON string containing column order.',
347
+ },
348
+ {
349
+ name: 'columnPinning',
350
+ type: 'String?',
351
+ description: 'JSON string containing column pinning state.',
352
+ },
353
+ {
354
+ name: 'columnSizing',
355
+ type: 'String?',
356
+ description: 'JSON string containing column sizing state.',
357
+ },
358
+ ],
359
+ faker: { items: 0 },
360
+ };
361
+ exports.defaultModelJson_Comment = {
362
+ name: exports.standardModelName_Comment,
363
+ description: 'A comment on a model entry, supporting threaded replies and resolution.',
364
+ schema: project_schema_defaults_1.databaseSchemaNameConfig,
365
+ standardFields: [defaults_1.standardFieldName_id, defaults_1.standardFieldName_createdAt],
366
+ labelField: defaults_1.standardFieldName_id,
367
+ fields: [
368
+ {
369
+ name: 'userId',
370
+ type: 'User',
371
+ description: 'The user who wrote the comment.',
372
+ },
373
+ {
374
+ name: 'model',
375
+ type: 'String',
376
+ description: 'The model this comment belongs to (e.g. "Deliverable").',
377
+ },
378
+ {
379
+ name: 'modelId',
380
+ type: 'String',
381
+ description: 'The id of the model entry this comment belongs to (e.g. "1.5.1").',
382
+ },
383
+ {
384
+ name: 'comment',
385
+ type: 'String',
386
+ description: 'The comment text.',
387
+ },
388
+ {
389
+ name: 'replyToCommentId',
390
+ type: 'Comment?',
391
+ description: 'If this comment is a reply, the id of the parent comment.',
392
+ },
393
+ {
394
+ name: 'isResolved',
395
+ type: 'Boolean?',
396
+ description: 'Whether this comment thread has been resolved.',
397
+ },
398
+ ],
399
+ faker: { items: 0 },
400
+ };
298
401
  exports.defaultModelsJson = {
299
402
  [exports.defaultModelName_Config]: exports.defaultModel_Config,
300
403
  [exports.standardModelName_User]: exports.defaultModelJson_User,
301
404
  [exports.standardModelName_Action]: exports.defaultModelJson_Action,
302
405
  [exports.standardModelName_ActionOperation]: exports.defaultModelJson_ActionOperation,
303
406
  [exports.standardModelName_File]: exports.defaultModelJson_File,
407
+ [exports.standardModelName_TableView]: exports.defaultModelJson_TableView,
408
+ [exports.standardModelName_Comment]: exports.defaultModelJson_Comment,
304
409
  };
@@ -111,7 +111,7 @@ exports.zProjectSchemaJSON = zod_1.z
111
111
  //
112
112
  .array(Model.zModelNameJSON)
113
113
  .optional().describe(`Names of standard models that should be included in the project.
114
- Currently, the following fields are supported: Config, User, Action, ActionOperation, File.
114
+ Currently, the following fields are supported: Config, User, Action, ActionOperation, File, TableView, Comment.
115
115
  If not provided, all models are included by default.
116
116
 
117
117
  If any of the standard models are also provided in the \`models\` array, the custom models will take precedence.`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/schema",
3
- "version": "1.3.1",
3
+ "version": "1.4.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",