@diagonal-hq/cli 0.2.0 → 0.3.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.
@@ -371,7 +371,7 @@ export type RelationInverse = {
371
371
  settings?: Omit<RelationFieldSettings, 'inverse'> & { "max_connections"?: number | null };
372
372
  };
373
373
 
374
- /** A relation names its target resource by id or slug. The type defaults to `belongs_to`. */
374
+ /** A relation names its target resource by slug, as `Resources.<Name>`. The type defaults to `belongs_to`. */
375
375
  export type RelationFieldOptions = Omit<BaseFieldOptions<RelationFieldSettings>, 'settings'> & { resource: string } & (
376
376
  | { type?: "belongs_to"; settings?: RelationFieldSettings }
377
377
  | { type: "belongs_to_many"; settings?: RelationFieldSettings & { "max_connections"?: number | null } }
package/dist/index.d.ts CHANGED
@@ -76,13 +76,8 @@ export type ResourceDataApi = {
76
76
  export type ResourceDefinition<
77
77
  TFields extends Record<string, FieldDefinition> = Record<string, FieldDefinition>
78
78
  > = {
79
- /**
80
- * A lowercase UUID v7, for example '0199f000-0000-7000-8000-000000000001'.
81
- * `diagonal check` suggests a new one when the id is not v7. Keep it
82
- * stable: records and workflows refer to it.
83
- */
84
- id: string;
85
- slug: string;
79
+ /** Only a platform resource reference sets `platform`. */
80
+ platform?: never;
86
81
  name: string;
87
82
  singularName: string;
88
83
  displayField?: Extract<keyof TFields, string>;
@@ -112,16 +107,22 @@ export type ResourceDefinition<
112
107
  capabilities?: ResourceCapabilities<TFields>;
113
108
  };
114
109
 
110
+ /**
111
+ * A resource that the platform provisions and owns, such as the roles. The
112
+ * file gives it a `Resources` entry. The deploy does not change it.
113
+ */
114
+ export type PlatformResourceDefinition = { platform: true };
115
+
115
116
  export declare function defineResource<const TFields extends Record<string, FieldDefinition>>(
116
- resource: ResourceDefinition<TFields>
117
- ): ResourceDefinition<TFields>;
117
+ resource: ResourceDefinition<TFields> | PlatformResourceDefinition
118
+ ): ResourceDefinition<TFields> | PlatformResourceDefinition;
118
119
 
119
120
  /** A TipTap document whose mentions resolve against the page's bound records. */
120
121
  export type PageMetaResolver = { readonly type: string; readonly [key: string]: unknown };
121
122
 
122
123
  export type PageRouteParam = {
123
- /** The slug or id of the resource whose record the parameter names. */
124
- resource: string;
124
+ /** The resource whose record the parameter names, as `Resources.<Name>`. */
125
+ resource: ResourceReference;
125
126
  /** The field the parameter matches. Defaults to the record id. */
126
127
  lookupField?: string | null;
127
128
  /** Relation fields to load with the record. */
@@ -133,8 +134,8 @@ export type PageAuthorizer =
133
134
  | null
134
135
  | 'authenticated'
135
136
  | {
136
- /** The slug or id of the resource whose signed-in records may view the page. */
137
- resource?: string | null;
137
+ /** The resource whose signed-in records may view the page, as `Resources.<Name>`. */
138
+ resource?: ResourceReference | null;
138
139
  /** Permission ids. A viewer needs any one of them. */
139
140
  permissions?: readonly string[];
140
141
  };
@@ -180,7 +181,11 @@ export type NavigationDefinition = { id: string; items: readonly NavigationItem[
180
181
 
181
182
  export declare function defineNavigation<const T extends NavigationDefinition>(navigation: T): T;
182
183
 
183
- /** The slug, name, or id of a resource. */
184
+ /**
185
+ * The slug of a resource: its file name in `resources/`. Use `Resources.<Name>`
186
+ * from `@app/generated/resources`, which `diagonal check` writes, so the editor
187
+ * and the build catch a wrong name. A slug string builds with a warning.
188
+ */
184
189
  export type ResourceReference = string;
185
190
 
186
191
  export type WorkflowRunAs =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {