@postxl/schema 2.5.0 → 2.6.0

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.
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
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
+ const brands_1 = require("../field/shared/brands");
38
39
  const project_schema_defaults_1 = require("../project-schema/project-schema.defaults");
39
40
  const Branded = __importStar(require("./model.brands"));
40
41
  exports.defaultModelName_Config = Branded.toModelName('Config');
@@ -249,6 +250,10 @@ Transformation: Depends on the transformation`,
249
250
  description: 'For mutation operations: the original entity before the mutation was executed. Null in case of a create mutation.',
250
251
  },
251
252
  ],
253
+ indexes: [
254
+ { fields: [defaults_1.standardFieldName_createdAt], unique: false, map: undefined },
255
+ { fields: [(0, brands_1.toFieldName)('actionId')], unique: false, map: undefined },
256
+ ],
252
257
  repository: { type: 'DatabaseDirect' },
253
258
  faker: { items: 0 },
254
259
  };
@@ -26,6 +26,10 @@ export declare const zSchemaJSON: z.ZodObject<{
26
26
  }, z.core.$strip>>;
27
27
  }, z.core.$strip>>;
28
28
  }, z.core.$strip>;
29
+ export declare const zDefaultRepositoryType: z.ZodEnum<{
30
+ DatabaseCached: "DatabaseCached";
31
+ DatabaseDirect: "DatabaseDirect";
32
+ }>;
29
33
  export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
30
34
  name: z.ZodString;
31
35
  slug: z.ZodString;
@@ -59,6 +63,10 @@ export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
59
63
  }, z.core.$strip>>;
60
64
  }, z.core.$strip>]>>>;
61
65
  defaultSchema: z.ZodOptional<z.ZodString>;
66
+ defaultRepositoryType: z.ZodOptional<z.ZodEnum<{
67
+ DatabaseCached: "DatabaseCached";
68
+ DatabaseDirect: "DatabaseDirect";
69
+ }>>;
62
70
  defaultLabelSeparator: z.ZodOptional<z.ZodString>;
63
71
  auth: z.ZodOptional<z.ZodObject<{
64
72
  provider: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"keycloak">>>;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.zProjectSchemaJSON = exports.zSchemaJSON = exports.zSchemaName = void 0;
36
+ exports.zProjectSchemaJSON = exports.zDefaultRepositoryType = exports.zSchemaJSON = exports.zSchemaName = void 0;
37
37
  const zod_1 = require("zod");
38
38
  const utils_1 = require("@postxl/utils");
39
39
  const Enum = __importStar(require("../enum"));
@@ -51,6 +51,7 @@ exports.zSchemaJSON = zod_1.z.object({
51
51
  name: exports.zSchemaName,
52
52
  auth: project_schema_auth_1.zAuthRuleSetJSON.optional(),
53
53
  });
54
+ exports.zDefaultRepositoryType = zod_1.z.enum(['DatabaseDirect', 'DatabaseCached']);
54
55
  exports.zProjectSchemaJSON = zod_1.z
55
56
  // We want to keep any extra fields that are not defined in the schema. However, these fields should
56
57
  // not really be exposed as "main fields" of the parsed schema - instead, they should be nested under
@@ -116,6 +117,10 @@ exports.zProjectSchemaJSON = zod_1.z
116
117
  //
117
118
  .optional()
118
119
  .describe(`The default database schema that is used if model/enum does not specify a schema. If not provided, the default schema "Data" is used.`),
120
+ defaultRepositoryType: exports.zDefaultRepositoryType
121
+ //
122
+ .optional()
123
+ .describe(`The default repository type used for models that omit \`repository.type\` ("DatabaseDirect" or "DatabaseCached"). Defaults to "DatabaseCached" when omitted.`),
119
124
  defaultLabelSeparator: zod_1.z
120
125
  //
121
126
  .string()
@@ -38,6 +38,10 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
38
38
  }, z.core.$strip>>;
39
39
  }, z.core.$strip>]>>>;
40
40
  defaultSchema: z.ZodOptional<z.ZodString>;
41
+ defaultRepositoryType: z.ZodOptional<z.ZodEnum<{
42
+ DatabaseCached: "DatabaseCached";
43
+ DatabaseDirect: "DatabaseDirect";
44
+ }>>;
41
45
  defaultLabelSeparator: z.ZodOptional<z.ZodString>;
42
46
  auth: z.ZodOptional<z.ZodObject<{
43
47
  provider: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"keycloak">>>;
@@ -166,6 +170,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
166
170
  } | undefined;
167
171
  })[] | undefined;
168
172
  defaultSchema?: string | undefined;
173
+ defaultRepositoryType?: "DatabaseCached" | "DatabaseDirect" | undefined;
169
174
  defaultLabelSeparator?: string | undefined;
170
175
  auth?: {
171
176
  provider: "keycloak";
@@ -95,6 +95,7 @@ function addDefaults(input) {
95
95
  schemas,
96
96
  schemaAuth,
97
97
  defaultSchema,
98
+ ...(input.defaultRepositoryType ? { defaultRepositoryType: input.defaultRepositoryType } : {}),
98
99
  defaultLabelSeparator: input.defaultLabelSeparator,
99
100
  ...(input.auth ? { auth: input.auth } : {}),
100
101
  systemUser: {
@@ -292,19 +293,15 @@ function transformModels(projectSchema, ctx) {
292
293
  // `defaultLabelSeparator` is only a fallback consulted while resolving each model's
293
294
  // `labelQualifier.separator` above; it is fully resolved by this point and must not leak
294
295
  // into the output (consumers never re-resolve it against project defaults).
295
- const { auth, defaultLabelSeparator: _defaultLabelSeparatorInput, ...remainingProjectSchema } = projectSchema;
296
- // Keep optional field shape clean: only include `auth` when it is actually set,
297
- // instead of returning `auth: undefined`.
298
- return auth
299
- ? {
300
- ...remainingProjectSchema,
301
- auth,
302
- models,
303
- }
304
- : {
305
- ...remainingProjectSchema,
306
- models,
307
- };
296
+ const { auth, defaultRepositoryType, defaultLabelSeparator: _defaultLabelSeparatorInput, ...remainingProjectSchema } = projectSchema;
297
+ // Keep optional field shape clean: only include optional fields when actually set,
298
+ // instead of returning `field: undefined`.
299
+ return {
300
+ ...remainingProjectSchema,
301
+ ...(auth ? { auth } : {}),
302
+ ...(defaultRepositoryType ? { defaultRepositoryType } : {}),
303
+ models,
304
+ };
308
305
  }
309
306
  /**
310
307
  * Rejects circular label-qualifier chains (e.g. Session qualified by Project qualified by
@@ -40,6 +40,12 @@ export type ProjectSchema = {
40
40
  * If not provided, the default schema "Data" is used.
41
41
  */
42
42
  defaultDatabaseSchema: Branded.DatabaseSchemaName;
43
+ /**
44
+ * The default repository type used for models that do not specify `repository.type`.
45
+ *
46
+ * If not provided, models default to `'DatabaseCached'` for backwards compatibility.
47
+ */
48
+ defaultRepositoryType?: DefaultRepositoryType;
43
49
  /**
44
50
  * The default roles for this project. Roles from auth rules are added on top of these.
45
51
  * If not provided in the schema, defaults to ['superadmin', 'admin', 'editor', 'viewer'].
@@ -81,6 +87,7 @@ export type ProjectSchema = {
81
87
  source: Record<string, unknown>;
82
88
  };
83
89
  export type ProjectType = 'standalone' | 'workspace';
90
+ export type DefaultRepositoryType = 'DatabaseDirect' | 'DatabaseCached';
84
91
  export type SystemUser = Record<string, unknown> & {
85
92
  id: string;
86
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/schema",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
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",
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsc -b tsconfig.build.json",
52
- "lint": "eslint .",
53
- "prettier:check": "prettier --check \"**/*.{ts,tsx}\" --config ../../prettier.config.js --ignore-path ../../.prettierignore",
52
+ "lint": "oxlint",
53
+ "format:check": "oxfmt --check \"**/*.{ts,tsx}\"",
54
54
  "test:jest": "jest",
55
55
  "test:coverage": "jest --coverage",
56
56
  "test:watch": "jest --watch",