@diagonal-hq/cli 0.32.1 → 0.33.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.
- package/README.md +126 -95
- package/dist/cli.mjs +574 -970
- package/dist/index.d.ts +75 -17
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,8 @@ export type WorkspaceFieldDefinition<T extends WorkspaceFieldType = WorkspaceFie
|
|
|
262
262
|
* name gives the `WorkspaceFields` name and follows the same rule.
|
|
263
263
|
*/
|
|
264
264
|
key?: string;
|
|
265
|
+
/** Groups the field on the Settings page. At most 255 characters. */
|
|
266
|
+
section?: string;
|
|
265
267
|
/**
|
|
266
268
|
* A `field.<type>({...})` call. A workspace field takes `label`,
|
|
267
269
|
* `description`, `required`, `guard`, and `settings`. `value` is its value:
|
|
@@ -484,14 +486,51 @@ export type ResourceDataApi = {
|
|
|
484
486
|
};
|
|
485
487
|
|
|
486
488
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
* `
|
|
489
|
+
* The metadata of each resource of the workspace, keyed by the name of its
|
|
490
|
+
* folder in `resources/`. `diagonal check` fills it in
|
|
491
|
+
* `generated/resources.ts`. A file of a resource folder names its folder in
|
|
492
|
+
* the type argument of its define call, such as `definePolicy<'posts'>`, to
|
|
493
|
+
* get the field keys of its resource. The build checks that the argument is
|
|
494
|
+
* the folder of the file.
|
|
495
|
+
*/
|
|
496
|
+
export interface WorkspaceResourceFolders {}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* The fields of the resource folder `TFolder`, as field definitions by key.
|
|
500
|
+
* A folder that `WorkspaceResourceFolders` does not have yet, such as a new
|
|
501
|
+
* resource before `diagonal check`, has open fields.
|
|
502
|
+
*/
|
|
503
|
+
export type ResourceFolderFields<TFolder extends string> =
|
|
504
|
+
TFolder extends keyof WorkspaceResourceFolders
|
|
505
|
+
? WorkspaceResourceFolders[TFolder] extends { readonly fields: infer TFields }
|
|
506
|
+
? {
|
|
507
|
+
[TKey in keyof TFields]: TFields[TKey] extends {
|
|
508
|
+
readonly type: infer TType extends FieldType;
|
|
509
|
+
}
|
|
510
|
+
? FieldDefinition<TType>
|
|
511
|
+
: FieldDefinition;
|
|
512
|
+
}
|
|
513
|
+
: Record<string, FieldDefinition>
|
|
514
|
+
: Record<string, FieldDefinition>;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* One record of a static resource, in `resources/<folder>/records/<key>.ts`:
|
|
518
|
+
* a value for each field key, and a `uid`. The uid is the record id in every
|
|
519
|
+
* environment, a UUID version 7 that `diagonal check` writes. Code names a
|
|
520
|
+
* record as `Resources.<Name>.records.<key>`, with its `uid` and the value of
|
|
521
|
+
* each field. The file name is the record key.
|
|
490
522
|
*/
|
|
491
523
|
export type StaticRecordDefinition<
|
|
492
524
|
TFields extends Record<string, FieldDefinition> = Record<string, FieldDefinition>
|
|
493
525
|
> = UidOption & { readonly [K in Extract<keyof TFields, string>]?: StaticValue };
|
|
494
526
|
|
|
527
|
+
/**
|
|
528
|
+
* The settings of a resource, in `resources/<folder>/resource.ts`. Each field
|
|
529
|
+
* is a file in `fields/`, each policy a file in `policies/`, and each record of
|
|
530
|
+
* a static resource a file in `records/` of the same folder. The folder name
|
|
531
|
+
* is the slug of a resource without a `slug` option, and it gives the name in
|
|
532
|
+
* `Resources`.
|
|
533
|
+
*/
|
|
495
534
|
export type ResourceDefinition<
|
|
496
535
|
TFields extends Record<string, FieldDefinition> = Record<string, FieldDefinition>
|
|
497
536
|
> = UidOption &
|
|
@@ -508,26 +547,21 @@ export type ResourceDefinition<
|
|
|
508
547
|
| Extract<keyof TFields, string>
|
|
509
548
|
| `${Extract<keyof TFields, string>}.${string}`
|
|
510
549
|
)[];
|
|
511
|
-
/**
|
|
550
|
+
/**
|
|
551
|
+
* The field keys that forms and tables show first, in this order. The
|
|
552
|
+
* other fields follow in the order in which they were made (their uid
|
|
553
|
+
* order), so a new field does not need an entry.
|
|
554
|
+
*/
|
|
512
555
|
fieldOrder?: readonly Extract<keyof TFields, string>[];
|
|
513
|
-
fields: TFields;
|
|
514
556
|
indexes?: readonly IndexDefinition<Extract<keyof TFields, string>>[];
|
|
515
557
|
embeddings?: ResourceEmbeddings<Extract<keyof TFields, string>>;
|
|
516
558
|
dataApi?: ResourceDataApi;
|
|
517
559
|
/**
|
|
518
|
-
* A static resource declares all of its records in `records
|
|
560
|
+
* A static resource declares all of its records in `records/`. The deploy
|
|
519
561
|
* writes them, and normal record writes to the resource are refused. A
|
|
520
562
|
* static resource has no capabilities and no relation fields of its own.
|
|
521
563
|
*/
|
|
522
564
|
static?: boolean;
|
|
523
|
-
/**
|
|
524
|
-
* Every record of a static resource, by record key, for example
|
|
525
|
-
* `{ standard: { uid: '019a…', name: 'Standard' } }`. Use `{}` for no records.
|
|
526
|
-
* Code names a record as `Resources.<Name>.records.<key>`, with its `uid`
|
|
527
|
-
* and the value of each field.
|
|
528
|
-
*/
|
|
529
|
-
records?: { readonly [key: string]: StaticRecordDefinition<TFields> };
|
|
530
|
-
policies: readonly PolicyDefinition<Extract<keyof TFields, string> | RecordMetaField>[];
|
|
531
565
|
/**
|
|
532
566
|
* The platform capabilities of the resource, keyed by capability. A field
|
|
533
567
|
* reference names a field of this resource by its key. The deploy validates
|
|
@@ -536,9 +570,33 @@ export type ResourceDefinition<
|
|
|
536
570
|
capabilities?: ResourceCapabilities<TFields>;
|
|
537
571
|
};
|
|
538
572
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
)
|
|
573
|
+
/**
|
|
574
|
+
* The settings of the resource in `resources/<folder>/resource.ts`. Give the
|
|
575
|
+
* folder as the type argument, `defineResource<'posts'>({...})`, to check the
|
|
576
|
+
* field keys of the settings against the fields of the resource.
|
|
577
|
+
*/
|
|
578
|
+
export declare function defineResource<TFolder extends string = string>(
|
|
579
|
+
resource: ResourceDefinition<ResourceFolderFields<TFolder>>
|
|
580
|
+
): ResourceDefinition<ResourceFolderFields<TFolder>>;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* One policy of a resource, in `resources/<folder>/policies/<key>.ts`. The
|
|
584
|
+
* file name gives its key in `Resources.<Name>.policies`. Give the folder as
|
|
585
|
+
* the type argument, `definePolicy<'posts'>({...})`, to check the field keys
|
|
586
|
+
* of `fields`.
|
|
587
|
+
*/
|
|
588
|
+
export declare function definePolicy<TFolder extends string = string>(
|
|
589
|
+
policy: PolicyDefinition<Extract<keyof ResourceFolderFields<TFolder>, string> | RecordMetaField>
|
|
590
|
+
): PolicyDefinition<Extract<keyof ResourceFolderFields<TFolder>, string> | RecordMetaField>;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* One record of a static resource, in `resources/<folder>/records/<key>.ts`.
|
|
594
|
+
* Give the folder as the type argument, `defineRecord<'rooms'>({...})`, to
|
|
595
|
+
* check the field keys of the values.
|
|
596
|
+
*/
|
|
597
|
+
export declare function defineRecord<TFolder extends string = string>(
|
|
598
|
+
record: StaticRecordDefinition<ResourceFolderFields<TFolder>>
|
|
599
|
+
): StaticRecordDefinition<ResourceFolderFields<TFolder>>;
|
|
542
600
|
|
|
543
601
|
/**
|
|
544
602
|
* A resolver object in a deprecated flat meta option. The build accepts only a
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,10 @@ export const defineRole = (role) => role;
|
|
|
31
31
|
|
|
32
32
|
export const defineResource = (resource) => resource;
|
|
33
33
|
|
|
34
|
+
export const definePolicy = (policy) => policy;
|
|
35
|
+
|
|
36
|
+
export const defineRecord = (record) => record;
|
|
37
|
+
|
|
34
38
|
export const definePage = (page, _component) => page;
|
|
35
39
|
|
|
36
40
|
// The build reads a text.template call in a seo function and never runs it.
|