@postxl/schema 2.1.0 → 2.2.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.
@@ -53,6 +53,7 @@ export declare const zModelJSON: z.ZodPreprocess<z.ZodObject<{
53
53
  visibleFor: z.ZodArray<z.ZodString>;
54
54
  }, z.core.$strip>>;
55
55
  }, z.core.$strip>>;
56
+ exposeRestApi: z.ZodOptional<z.ZodBoolean>;
56
57
  schema: z.ZodOptional<z.ZodString>;
57
58
  databaseName: z.ZodOptional<z.ZodString>;
58
59
  excelName: z.ZodOptional<z.ZodString>;
@@ -68,6 +68,13 @@ exports.zModelJSON = zod_1.z.preprocess((input) => {
68
68
  .optional()
69
69
  .describe(`Indicates if the model is readonly. To be used for system models that should not be editable through actions (e.g. Mutation, Action).`),
70
70
  auth: project_schema_auth_1.zAuthRuleSetJSON.optional().describe('Authorization rules for this model.'),
71
+ exposeRestApi: zod_1.z
72
+ .boolean()
73
+ .optional()
74
+ .describe(`Expose this model through the generated REST API (\`backend-rest-api\`). Defaults to \`false\`.
75
+ Opt-in is deliberate: forgetting to opt out would silently publish the model's rows,
76
+ whereas forgetting to opt in only produces a missing route. The REST API as a whole is
77
+ additionally gated behind the \`REST_API_ENABLED\` environment variable.`),
71
78
  //
72
79
  schema: zod_1.z
73
80
  //
@@ -14,6 +14,7 @@ export declare function modelJSONTransformer(input: ModelJSON, ctx: z.Refinement
14
14
  keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
15
15
  defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
16
16
  isReadonly: boolean;
17
+ exposeRestApi: boolean;
17
18
  excelName: string;
18
19
  description: string;
19
20
  indexes: ({
@@ -58,6 +59,7 @@ export declare function modelJSONTransformer(input: ModelJSON, ctx: z.Refinement
58
59
  export type ModelEnriched = ReturnType<typeof modelJSONTransformer>;
59
60
  declare function addDefaults({ description, fields, standardFields, seed, faker, ...input }: ModelJSON): {
60
61
  isReadonly: boolean;
62
+ exposeRestApi: boolean;
61
63
  databaseName: string;
62
64
  excelName: string;
63
65
  description: string;
@@ -122,6 +124,7 @@ declare function brandModel({ name, schema, databaseName, standardFields, defaul
122
124
  keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
123
125
  defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
124
126
  isReadonly: boolean;
127
+ exposeRestApi: boolean;
125
128
  excelName: string;
126
129
  description: string;
127
130
  fields: {
@@ -182,6 +185,7 @@ declare function combineFields({ fields, standardFields, ...model }: BrandedMode
182
185
  keyFieldName: (string & z.core.$brand<"PXL.FieldName">) | undefined;
183
186
  defaultSort: (string & z.core.$brand<"PXL.FieldName">)[] | undefined;
184
187
  isReadonly: boolean;
188
+ exposeRestApi: boolean;
185
189
  excelName: string;
186
190
  description: string;
187
191
  indexes: ({
@@ -51,6 +51,7 @@ function addDefaults({ description, fields, standardFields, seed, faker, ...inpu
51
51
  return {
52
52
  ...input,
53
53
  isReadonly: input.isReadonly ?? false,
54
+ exposeRestApi: input.exposeRestApi ?? false,
54
55
  databaseName: input.databaseName ?? (0, utils_1.toSnakeCase)(input.name),
55
56
  excelName: input.excelName ?? (0, utils_1.toExcelColumnName)((0, utils_1.toPascalCase)((0, utils_1.pluralize)(input.name))),
56
57
  description: description ?? '',
@@ -7,6 +7,10 @@ export type Model = {
7
7
  name: Branded.ModelName;
8
8
  description: string;
9
9
  isReadonly: boolean;
10
+ /**
11
+ * Whether the model is exposed through the generated REST API. Defaults to `false`.
12
+ */
13
+ exposeRestApi: boolean;
10
14
  databaseSchema: DatabaseSchemaName;
11
15
  databaseName: string;
12
16
  excelName: string;
@@ -99,6 +99,7 @@ export declare const zProjectSchemaJSON: z.ZodPreprocess<z.ZodObject<{
99
99
  visibleFor: z.ZodArray<z.ZodString>;
100
100
  }, z.core.$strip>>;
101
101
  }, z.core.$strip>>;
102
+ exposeRestApi: z.ZodOptional<z.ZodBoolean>;
102
103
  schema: z.ZodOptional<z.ZodString>;
103
104
  databaseName: z.ZodOptional<z.ZodString>;
104
105
  excelName: z.ZodOptional<z.ZodString>;
@@ -78,6 +78,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
78
78
  visibleFor: z.ZodArray<z.ZodString>;
79
79
  }, z.core.$strip>>;
80
80
  }, z.core.$strip>>;
81
+ exposeRestApi: z.ZodOptional<z.ZodBoolean>;
81
82
  schema: z.ZodOptional<z.ZodString>;
82
83
  databaseName: z.ZodOptional<z.ZodString>;
83
84
  excelName: z.ZodOptional<z.ZodString>;
@@ -201,6 +202,7 @@ export declare const zProjectSchema: z.ZodPipe<z.ZodPreprocess<z.ZodObject<{
201
202
  visibleFor: string[];
202
203
  } | undefined;
203
204
  } | undefined;
205
+ exposeRestApi?: boolean | undefined;
204
206
  schema?: string | undefined;
205
207
  databaseName?: string | undefined;
206
208
  excelName?: string | undefined;
@@ -1771,6 +1771,7 @@ export declare const sampleSchemas: {
1771
1771
  faker: {
1772
1772
  items: number;
1773
1773
  };
1774
+ exposeRestApi?: never;
1774
1775
  standardFields?: never;
1775
1776
  labelField?: never;
1776
1777
  standardActions?: never;
@@ -1781,6 +1782,7 @@ export declare const sampleSchemas: {
1781
1782
  name: string;
1782
1783
  description: string;
1783
1784
  schema: string;
1785
+ exposeRestApi: boolean;
1784
1786
  fields: ({
1785
1787
  name: string;
1786
1788
  type: string;
@@ -1857,6 +1859,7 @@ export declare const sampleSchemas: {
1857
1859
  };
1858
1860
  defaultField?: never;
1859
1861
  seed?: never;
1862
+ exposeRestApi?: never;
1860
1863
  standardFields?: never;
1861
1864
  labelField?: never;
1862
1865
  isReadonly?: never;
@@ -1886,6 +1889,7 @@ export declare const sampleSchemas: {
1886
1889
  defaultField?: never;
1887
1890
  seed?: never;
1888
1891
  faker?: never;
1892
+ exposeRestApi?: never;
1889
1893
  labelField?: never;
1890
1894
  standardActions?: never;
1891
1895
  actions?: never;
@@ -69,6 +69,7 @@
69
69
  "name": "Post",
70
70
  "description": "A blog post entry.",
71
71
  "schema": "Data",
72
+ "exposeRestApi": true,
72
73
  "fields": [
73
74
  {
74
75
  "name": "title",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/schema",
3
- "version": "2.1.0",
3
+ "version": "2.2.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",
@@ -36,7 +36,7 @@
36
36
  "directory": "packages/schema"
37
37
  },
38
38
  "dependencies": {
39
- "@postxl/utils": "^1.4.1"
39
+ "@postxl/utils": "^1.4.2"
40
40
  },
41
41
  "devDependencies": {},
42
42
  "wallaby": {