@diagonal-hq/cli 0.1.0 → 0.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.
- package/README.md +178 -12
- package/dist/capabilities.generated.d.ts +397 -0
- package/dist/cli.mjs +14176 -652
- package/dist/fields.generated.d.ts +416 -0
- package/dist/fields.generated.js +35 -0
- package/dist/index.d.ts +157 -63
- package/dist/index.js +10 -17
- package/dist/sdk-contract.d.ts +27 -5
- package/dist/workflow/data.d.ts +10 -0
- package/dist/workflow/generated/capabilities.d.ts +27 -26
- package/dist/workflow/notifications.d.ts +1 -1
- package/dist/workflow/workflow.d.ts +3 -1
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './globals';
|
|
2
|
+
import type { ResourceCapabilities } from './capabilities.generated';
|
|
3
|
+
import type { DataApiEndpoint, FieldDefinition, FieldType } from './fields.generated';
|
|
2
4
|
|
|
3
5
|
// The configuration helpers of file-based workspaces. The workspace build
|
|
4
6
|
// reads these calls as static data. index.js implements each define* function
|
|
@@ -20,62 +22,19 @@ export type ConfigDefinition = {
|
|
|
20
22
|
|
|
21
23
|
export declare function defineConfig<const T extends ConfigDefinition>(config: T): T;
|
|
22
24
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export type FieldOptions = {
|
|
38
|
-
label?: string;
|
|
39
|
-
description?: string | null;
|
|
40
|
-
required?: boolean;
|
|
41
|
-
unique?: boolean;
|
|
42
|
-
index?: boolean;
|
|
43
|
-
default?: StaticValue;
|
|
44
|
-
[setting: string]: StaticValue | undefined;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type SelectOption = { label: string; value: string };
|
|
48
|
-
|
|
49
|
-
export type SelectFieldOptions = FieldOptions & { options: readonly SelectOption[] };
|
|
50
|
-
|
|
51
|
-
export type RelationType = 'belongs_to' | 'has_many' | 'belongs_to_many';
|
|
52
|
-
|
|
53
|
-
export type RelationFieldOptions = FieldOptions & {
|
|
54
|
-
/** The id or slug of the related resource. */
|
|
55
|
-
resource: string;
|
|
56
|
-
type?: RelationType;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export type FieldDefinition<TType extends FieldType = FieldType> = {
|
|
60
|
-
readonly $field: TType;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export declare const field: {
|
|
64
|
-
text(options?: FieldOptions): FieldDefinition<'text'>;
|
|
65
|
-
/** Stored as a `text` field. */
|
|
66
|
-
longText(options?: FieldOptions): FieldDefinition<'text'>;
|
|
67
|
-
email(options?: FieldOptions): FieldDefinition<'email'>;
|
|
68
|
-
number(options?: FieldOptions): FieldDefinition<'number'>;
|
|
69
|
-
boolean(options?: FieldOptions): FieldDefinition<'boolean'>;
|
|
70
|
-
date(options?: FieldOptions): FieldDefinition<'date'>;
|
|
71
|
-
datetime(options?: FieldOptions): FieldDefinition<'datetime'>;
|
|
72
|
-
phone(options?: FieldOptions): FieldDefinition<'phone'>;
|
|
73
|
-
url(options?: FieldOptions): FieldDefinition<'url'>;
|
|
74
|
-
select(options: SelectFieldOptions): FieldDefinition<'select'>;
|
|
75
|
-
money(options?: FieldOptions): FieldDefinition<'money'>;
|
|
76
|
-
markdown(options?: FieldOptions): FieldDefinition<'markdown'>;
|
|
77
|
-
relation(options: RelationFieldOptions): FieldDefinition<'relation'>;
|
|
78
|
-
};
|
|
25
|
+
export { field } from './fields.generated';
|
|
26
|
+
export type {
|
|
27
|
+
CommonFieldSettings,
|
|
28
|
+
DataApiEndpoint,
|
|
29
|
+
FieldDefinition,
|
|
30
|
+
FieldSchemaDefinition,
|
|
31
|
+
FieldSchemaSetting,
|
|
32
|
+
FieldType,
|
|
33
|
+
RelationFieldOptions,
|
|
34
|
+
RelationInverse,
|
|
35
|
+
Resolver
|
|
36
|
+
} from './fields.generated';
|
|
37
|
+
export type { CapabilityType, FieldKeyOf, ResourceCapabilities } from './capabilities.generated';
|
|
79
38
|
|
|
80
39
|
export type PolicyScope =
|
|
81
40
|
| 'index'
|
|
@@ -103,6 +62,17 @@ export type IndexDefinition<TKey extends string = string> = {
|
|
|
103
62
|
unique?: boolean;
|
|
104
63
|
};
|
|
105
64
|
|
|
65
|
+
export type ResourceEmbeddings<TKey extends string = string> = {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
/** Field keys. Relation paths are not allowed. */
|
|
68
|
+
fields?: readonly TKey[] | null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type ResourceDataApi = {
|
|
72
|
+
/** An omitted endpoint stays enabled. */
|
|
73
|
+
endpoints?: Partial<Record<DataApiEndpoint, { enabled?: boolean }>>;
|
|
74
|
+
};
|
|
75
|
+
|
|
106
76
|
export type ResourceDefinition<
|
|
107
77
|
TFields extends Record<string, FieldDefinition> = Record<string, FieldDefinition>
|
|
108
78
|
> = {
|
|
@@ -116,9 +86,30 @@ export type ResourceDefinition<
|
|
|
116
86
|
name: string;
|
|
117
87
|
singularName: string;
|
|
118
88
|
displayField?: Extract<keyof TFields, string>;
|
|
89
|
+
/**
|
|
90
|
+
* The field keys and relation paths that record search matches, for example
|
|
91
|
+
* `['title', 'body', 'author.full_name']`. Without it, search matches the
|
|
92
|
+
* display field and every text and markdown field.
|
|
93
|
+
*/
|
|
94
|
+
searchableFields?: readonly (
|
|
95
|
+
| Extract<keyof TFields, string>
|
|
96
|
+
| `${Extract<keyof TFields, string>}.${string}`
|
|
97
|
+
)[];
|
|
98
|
+
/** Every field key once, in the order that forms and tables show them. Defaults to the order of `fields`. */
|
|
99
|
+
fieldOrder?: readonly Extract<keyof TFields, string>[];
|
|
119
100
|
fields: TFields;
|
|
120
101
|
indexes?: readonly IndexDefinition<Extract<keyof TFields, string>>[];
|
|
102
|
+
embeddings?: ResourceEmbeddings<Extract<keyof TFields, string>>;
|
|
103
|
+
dataApi?: ResourceDataApi;
|
|
104
|
+
/** A static resource refuses normal record writes. */
|
|
105
|
+
static?: boolean;
|
|
121
106
|
policies: readonly PolicyDefinition[];
|
|
107
|
+
/**
|
|
108
|
+
* The platform capabilities of the resource, keyed by capability. A field
|
|
109
|
+
* reference names a field of this resource by its key. The deploy validates
|
|
110
|
+
* each capability against the deployed schema and runs its provisioning.
|
|
111
|
+
*/
|
|
112
|
+
capabilities?: ResourceCapabilities<TFields>;
|
|
122
113
|
};
|
|
123
114
|
|
|
124
115
|
export declare function defineResource<const TFields extends Record<string, FieldDefinition>>(
|
|
@@ -183,13 +174,6 @@ export declare function definePage<const T extends PageDefinition>(
|
|
|
183
174
|
|
|
184
175
|
export type LayoutProps = { children?: React.ReactNode };
|
|
185
176
|
|
|
186
|
-
export type EmailDefinition = { subject: string };
|
|
187
|
-
|
|
188
|
-
export declare function defineEmail<const T extends EmailDefinition, P>(
|
|
189
|
-
email: T,
|
|
190
|
-
component: (props: P) => unknown
|
|
191
|
-
): T;
|
|
192
|
-
|
|
193
177
|
export type NavigationItem = { label: string; route: string; icon?: string | null };
|
|
194
178
|
|
|
195
179
|
export type NavigationDefinition = { id: string; items: readonly NavigationItem[] };
|
|
@@ -272,3 +256,113 @@ export type WorkflowConfig =
|
|
|
272
256
|
})
|
|
273
257
|
| (ConfigBase & { trigger: ManualTrigger; runAs?: Exclude<WorkflowRunAs, 'session'> })
|
|
274
258
|
| (ConfigBase & { trigger: RecordLifecycleTrigger });
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Liquid source: inline text, or the path of a `.liquid` file relative to the
|
|
262
|
+
* definition file, for example `{ file: './standard.email.liquid' }`.
|
|
263
|
+
*/
|
|
264
|
+
export type LiquidSource = string | { readonly file: `./${string}.liquid` };
|
|
265
|
+
|
|
266
|
+
/** The key of a notification type. */
|
|
267
|
+
export type NotificationTypeReference = string;
|
|
268
|
+
|
|
269
|
+
/** The key of a template, unique within its notification type. */
|
|
270
|
+
export type NotificationTemplateReference = string;
|
|
271
|
+
|
|
272
|
+
/** The key of an email layout, or `'default'` for the built-in layout. */
|
|
273
|
+
export type EmailLayoutReference = string;
|
|
274
|
+
|
|
275
|
+
/** A variable whose value is one record. The sender passes the record id. */
|
|
276
|
+
export type RecordVariableDefinition = {
|
|
277
|
+
/** The slug of the resource whose record the sender passes. */
|
|
278
|
+
resource: ResourceReference;
|
|
279
|
+
label?: string;
|
|
280
|
+
description?: string | null;
|
|
281
|
+
required?: boolean;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* A value that the sender passes to the notification. The name cannot be
|
|
286
|
+
* `record` or `ref`: templates read the recipient as `{{ record.* }}` and the
|
|
287
|
+
* generators as `{{ ref.* }}`.
|
|
288
|
+
*/
|
|
289
|
+
export type NotificationVariableDefinition =
|
|
290
|
+
| FieldDefinition<Exclude<FieldType, 'relation'>>
|
|
291
|
+
| RecordVariableDefinition;
|
|
292
|
+
|
|
293
|
+
/** A `notifications/<key>/type.ts` file. */
|
|
294
|
+
export type NotificationTypeDefinition = {
|
|
295
|
+
/**
|
|
296
|
+
* Lowercase letters, digits, and hyphens, for example `'member-welcome'`.
|
|
297
|
+
* Templates, fixtures, and workflows refer to it. Moving the file keeps it.
|
|
298
|
+
*/
|
|
299
|
+
key: string;
|
|
300
|
+
name: string;
|
|
301
|
+
/**
|
|
302
|
+
* The resource that receives the notification. The resource maps the email
|
|
303
|
+
* and phone fields. Leave it out to send to email addresses.
|
|
304
|
+
*/
|
|
305
|
+
recipient?: { resource: ResourceReference };
|
|
306
|
+
variables?: { readonly [key: string]: NotificationVariableDefinition };
|
|
307
|
+
defaultTemplate: NotificationTemplateReference;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export declare function defineNotificationType<const T extends NotificationTypeDefinition>(
|
|
311
|
+
type: T
|
|
312
|
+
): T;
|
|
313
|
+
|
|
314
|
+
export type NotificationReference = {
|
|
315
|
+
label: string;
|
|
316
|
+
/** The server generator, for example `'page.url'` or `'workspace.login_url'`. */
|
|
317
|
+
generator: string;
|
|
318
|
+
settings?: { readonly [setting: string]: StaticValue };
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export type NotificationTemplateEmail = {
|
|
322
|
+
subject: string;
|
|
323
|
+
/** Defaults to `'default'`, the built-in layout with one field, `content`. */
|
|
324
|
+
layout?: EmailLayoutReference;
|
|
325
|
+
/** A value for each field of the layout. */
|
|
326
|
+
fields: { readonly [field: string]: LiquidSource };
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export type NotificationTemplateSms = { body: LiquidSource };
|
|
330
|
+
|
|
331
|
+
/** A `notifications/<type key>/<key>.template.ts` file. A template has an email, an SMS, or both. */
|
|
332
|
+
export type NotificationTemplateDefinition = {
|
|
333
|
+
/** Unique within its type, for example `'standard'`. */
|
|
334
|
+
key: string;
|
|
335
|
+
type: NotificationTypeReference;
|
|
336
|
+
name: string;
|
|
337
|
+
/** Generators that the template reads as `{{ ref.<key> }}`. */
|
|
338
|
+
references?: { readonly [key: string]: NotificationReference };
|
|
339
|
+
} & (
|
|
340
|
+
| { email: NotificationTemplateEmail; sms?: NotificationTemplateSms }
|
|
341
|
+
| { email?: NotificationTemplateEmail; sms: NotificationTemplateSms }
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
export declare function defineNotificationTemplate<const T extends NotificationTemplateDefinition>(
|
|
345
|
+
template: T
|
|
346
|
+
): T;
|
|
347
|
+
|
|
348
|
+
/** A slot in the layout body. A template fills it with Liquid. */
|
|
349
|
+
export type EmailLayoutFieldDefinition = {
|
|
350
|
+
label: string;
|
|
351
|
+
description?: string | null;
|
|
352
|
+
required?: boolean;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/** An `email-layouts/<key>/layout.ts` file. */
|
|
356
|
+
export type EmailLayoutDefinition = {
|
|
357
|
+
/**
|
|
358
|
+
* Lowercase letters, digits, and hyphens, for example `'standard'`. Templates
|
|
359
|
+
* refer to it. `'default'` is the built-in layout.
|
|
360
|
+
*/
|
|
361
|
+
key: string;
|
|
362
|
+
name: string;
|
|
363
|
+
body: LiquidSource;
|
|
364
|
+
/** The fields that each template fills in. The body reads them as `{{ <field> }}`. */
|
|
365
|
+
fields?: { readonly [key: string]: EmailLayoutFieldDefinition };
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export declare function defineEmailLayout<const T extends EmailLayoutDefinition>(layout: T): T;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// data, so the helpers only return their argument. A Vite build or a Node
|
|
3
3
|
// script that imports a configuration file runs them.
|
|
4
4
|
//
|
|
5
|
+
// The field builders come from fields.generated.js, which
|
|
6
|
+
// `artisan app:generate-custom-typescript` generates from the field types.
|
|
7
|
+
//
|
|
5
8
|
// Each function must not refer to anything outside its own body:
|
|
6
9
|
// scripts/lib/runtime-build/app-modules.mjs copies their source into the
|
|
7
10
|
// workspace modules that a page or a workflow imports.
|
|
@@ -12,22 +15,12 @@ export const defineResource = (resource) => resource;
|
|
|
12
15
|
|
|
13
16
|
export const definePage = (page, _component) => page;
|
|
14
17
|
|
|
15
|
-
export const defineEmail = (email, _component) => email;
|
|
16
|
-
|
|
17
18
|
export const defineNavigation = (navigation) => navigation;
|
|
18
19
|
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
datetime: (options = {}) => ({ $field: 'datetime', ...options }),
|
|
27
|
-
phone: (options = {}) => ({ $field: 'phone', ...options }),
|
|
28
|
-
url: (options = {}) => ({ $field: 'url', ...options }),
|
|
29
|
-
select: (options) => ({ $field: 'select', ...options }),
|
|
30
|
-
money: (options = {}) => ({ $field: 'money', ...options }),
|
|
31
|
-
markdown: (options = {}) => ({ $field: 'markdown', ...options }),
|
|
32
|
-
relation: (options) => ({ $field: 'relation', ...options })
|
|
33
|
-
};
|
|
20
|
+
export const defineNotificationType = (type) => type;
|
|
21
|
+
|
|
22
|
+
export const defineNotificationTemplate = (template) => template;
|
|
23
|
+
|
|
24
|
+
export const defineEmailLayout = (layout) => layout;
|
|
25
|
+
|
|
26
|
+
export { field } from './fields.generated.js';
|
package/dist/sdk-contract.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ type SdkResourceField = {
|
|
|
119
119
|
settings: SdkResourceFieldSettings;
|
|
120
120
|
/** Dotted accessor path; equals `key` at the top level, `parent.key` once nested. */
|
|
121
121
|
path: string;
|
|
122
|
+
/** A Boolean field's configured default; form checkboxes start from it. */
|
|
123
|
+
default_value?: boolean | null;
|
|
122
124
|
/** Relation-only decoration, filled lazily by the SDK builder from the flat catalog. */
|
|
123
125
|
display_field_key?: string | null;
|
|
124
126
|
column_label?: string | null;
|
|
@@ -2327,7 +2329,7 @@ type SdkScheduledNotificationDetail = Omit<SdkUpcomingNotification, 'status'> &
|
|
|
2327
2329
|
|
|
2328
2330
|
type SdkScheduledNotificationEdits = {
|
|
2329
2331
|
recipient?: SdkNotificationRecipient;
|
|
2330
|
-
/** Omit to retain content. Null restores the shared template.
|
|
2332
|
+
/** Omit to retain content. Null restores the shared template. Use raw content from ScheduledNotificationComposer, not resolved NotificationComposer output. */
|
|
2331
2333
|
content_override?: SdkScheduledNotificationContent | null;
|
|
2332
2334
|
};
|
|
2333
2335
|
|
|
@@ -6080,6 +6082,7 @@ type ComponentRegistry = {
|
|
|
6080
6082
|
"ResourceTable": <TResource extends ResourceDataTableResource, const TRelations extends readonly SdkResourceRelationPath<NoInfer<TResource>>[] = readonly []>(props: ResourceTableProps<TResource, TRelations>) => any;
|
|
6081
6083
|
"RestoreResourceRecord": SdkComponent<RestoreResourceRecordProps>;
|
|
6082
6084
|
"RichText": SdkComponent<RichTextProps>;
|
|
6085
|
+
"ScheduledNotificationComposer": SdkComponent<ScheduledNotificationComposerProps>;
|
|
6083
6086
|
"SearchBar": SdkComponent<SearchBarProps>;
|
|
6084
6087
|
"Separator": SdkComponent<SeparatorProps>;
|
|
6085
6088
|
"SharedFilters": SdkComponent<SharedFiltersProps>;
|
|
@@ -6408,8 +6411,9 @@ type SdkHooks = {
|
|
|
6408
6411
|
|
|
6409
6412
|
/**
|
|
6410
6413
|
* List the accounting entities of the workspace with their `active` and `is_default`
|
|
6411
|
-
* flags, ordered by name. Inactive entities are included. A branch
|
|
6412
|
-
*
|
|
6414
|
+
* flags, ordered by name. Inactive entities are included. A branch returns the copies
|
|
6415
|
+
* of its production workspace's entities. A signed-out visitor gets an empty list and
|
|
6416
|
+
* no request is made,
|
|
6413
6417
|
* so a public page reads the entity of a record from `record.__meta?.accounting_entity`
|
|
6414
6418
|
* instead. ShowRecord and IndexRecords add it to each invoice, subscription, and payer
|
|
6415
6419
|
* balance entry record whose entity field the visitor can read. ShowRecord (`useRecord`)
|
|
@@ -7469,7 +7473,7 @@ type SdkHooks = {
|
|
|
7469
7473
|
/**
|
|
7470
7474
|
* Form state for editing workspace field values, for layouts that must escape the
|
|
7471
7475
|
* managed `Sdk.Components.WorkspaceFieldsForm` shell. Submits to
|
|
7472
|
-
* `PUT /api/data/workspace-fields/values`; requires `update_workspace_fields
|
|
7476
|
+
* `PUT /api/data/workspace-fields/values`; requires `update_workspace_fields` or `manage_workspace_fields`
|
|
7473
7477
|
* permission.
|
|
7474
7478
|
*
|
|
7475
7479
|
* @example
|
|
@@ -8274,7 +8278,7 @@ type UseWorkspaceFieldsFormResult = {
|
|
|
8274
8278
|
form: SdkWorkspaceFieldsForm;
|
|
8275
8279
|
/** The active field definitions, in render order. */
|
|
8276
8280
|
fields: SdkWorkspaceField[];
|
|
8277
|
-
/** Whether a save can happen: the identity holds `update_workspace_fields
|
|
8281
|
+
/** Whether a save can happen: the identity holds `update_workspace_fields` or `manage_workspace_fields` and at
|
|
8278
8282
|
* least one field or fixed value is active. `submit()` is a no-op otherwise. */
|
|
8279
8283
|
canSubmit: boolean;
|
|
8280
8284
|
/** Context-wired input for one workspace field. Must be rendered inside `Form`. */
|
|
@@ -12690,6 +12694,24 @@ type RichTextProps = {
|
|
|
12690
12694
|
className?: string;
|
|
12691
12695
|
};
|
|
12692
12696
|
|
|
12697
|
+
type ScheduledNotificationComposerProps = {
|
|
12698
|
+
/** The occurrence to open, such as an id from useUpcomingNotifications. */
|
|
12699
|
+
scheduledNotificationId: string;
|
|
12700
|
+
/** Edited raw content, ready to save as content_override. Null while nothing changed, and when the occurrence cannot be edited. */
|
|
12701
|
+
onChange: (content: SdkScheduledNotificationContent | null) => void;
|
|
12702
|
+
/** Preview for an unsaved recipient change instead of the saved recipient. */
|
|
12703
|
+
recipient?: SdkNotificationRecipient;
|
|
12704
|
+
/** Omit to allow every text layout field. An empty array locks every layout field. */
|
|
12705
|
+
editableFields?: string[];
|
|
12706
|
+
/** Allow subject edits. Defaults to true. */
|
|
12707
|
+
editableSubject?: boolean;
|
|
12708
|
+
/** Lock all editors while the parent saves. */
|
|
12709
|
+
disabled?: boolean;
|
|
12710
|
+
/** Called when the occurrence cannot be loaded. */
|
|
12711
|
+
onError?: (error: SdkApiError) => void;
|
|
12712
|
+
className?: string;
|
|
12713
|
+
};
|
|
12714
|
+
|
|
12693
12715
|
type SearchBarProps = {
|
|
12694
12716
|
/**
|
|
12695
12717
|
* Called with the debounced search value.
|
package/dist/workflow/data.d.ts
CHANGED
|
@@ -4,6 +4,16 @@ type Entry = WorkspaceResources[keyof WorkspaceResources];
|
|
|
4
4
|
export type ResourceKey = [keyof WorkspaceResources] extends [never] ? string : Entry extends {
|
|
5
5
|
id: infer I;
|
|
6
6
|
} ? I : never;
|
|
7
|
+
/** The id of each entry of `E` that has every capability in `C`. */
|
|
8
|
+
type IdWithCapabilities<E, C extends string> = E extends {
|
|
9
|
+
id: infer I;
|
|
10
|
+
capabilities: infer Declared;
|
|
11
|
+
} ? [C] extends [Declared] ? I : never : never;
|
|
12
|
+
/**
|
|
13
|
+
* The ids of the resources that have every capability in `C`. Any string while the workspace
|
|
14
|
+
* declares no resources.
|
|
15
|
+
*/
|
|
16
|
+
export type ResourceKeyWith<C extends string> = [keyof WorkspaceResources] extends [never] ? string : IdWithCapabilities<Entry, C>;
|
|
7
17
|
type EntryFor<R> = Extract<Entry, {
|
|
8
18
|
id: R;
|
|
9
19
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ResourceKeyWith } from '../data';
|
|
1
2
|
import type { ContentDocument } from '../input';
|
|
2
|
-
export declare const SDK_VERSION =
|
|
3
|
+
export declare const SDK_VERSION = 55;
|
|
3
4
|
export interface AiDecideInput {
|
|
4
5
|
state: unknown;
|
|
5
6
|
questions: Array<{
|
|
@@ -24,7 +25,7 @@ export interface AiRunPromptInput {
|
|
|
24
25
|
}
|
|
25
26
|
export type AiRunPromptOutput = string;
|
|
26
27
|
export interface AuthImpersonateInput {
|
|
27
|
-
resource:
|
|
28
|
+
resource: ResourceKeyWith<"authenticatable">;
|
|
28
29
|
record: string;
|
|
29
30
|
}
|
|
30
31
|
export type AuthImpersonateOutput = {
|
|
@@ -34,18 +35,18 @@ export type AuthImpersonateOutput = {
|
|
|
34
35
|
[key: string]: unknown;
|
|
35
36
|
};
|
|
36
37
|
export interface AuthLoginInput {
|
|
37
|
-
resource:
|
|
38
|
+
resource: ResourceKeyWith<"authenticatable">;
|
|
38
39
|
record: string;
|
|
39
40
|
}
|
|
40
41
|
export type AuthLoginOutput = boolean;
|
|
41
42
|
export interface CalendarGenerateLinkInput {
|
|
42
43
|
type: "apple" | "google" | "outlook";
|
|
43
|
-
resource:
|
|
44
|
+
resource: ResourceKeyWith<"eventable">;
|
|
44
45
|
record: string;
|
|
45
46
|
}
|
|
46
47
|
export type CalendarGenerateLinkOutput = unknown;
|
|
47
48
|
export interface CalendarSearchEventsInput {
|
|
48
|
-
resource:
|
|
49
|
+
resource: ResourceKeyWith<"eventable">;
|
|
49
50
|
from: string;
|
|
50
51
|
to: string;
|
|
51
52
|
filters?: unknown;
|
|
@@ -639,7 +640,7 @@ export interface MoneyFormatInput {
|
|
|
639
640
|
}
|
|
640
641
|
export type MoneyFormatOutput = string;
|
|
641
642
|
export interface NotificationSendInput {
|
|
642
|
-
resource:
|
|
643
|
+
resource: ResourceKeyWith<"notifiable">;
|
|
643
644
|
relations?: Array<string>;
|
|
644
645
|
record: string;
|
|
645
646
|
subject: string;
|
|
@@ -700,7 +701,7 @@ export interface NotificationSendNotificationInput {
|
|
|
700
701
|
}
|
|
701
702
|
export type NotificationSendNotificationOutput = boolean;
|
|
702
703
|
export interface NotificationSetConsentInput {
|
|
703
|
-
resource:
|
|
704
|
+
resource: ResourceKeyWith<"notifiable">;
|
|
704
705
|
record: string;
|
|
705
706
|
sms?: boolean | null;
|
|
706
707
|
email?: boolean | null;
|
|
@@ -730,7 +731,7 @@ export type PageUrlOutput = unknown;
|
|
|
730
731
|
export interface PayablesVoidInput {
|
|
731
732
|
reason?: string | null;
|
|
732
733
|
effectiveDate?: string | null;
|
|
733
|
-
payableResource:
|
|
734
|
+
payableResource: ResourceKeyWith<"payable">;
|
|
734
735
|
payableRecord: string;
|
|
735
736
|
}
|
|
736
737
|
export type PayablesVoidOutput = {
|
|
@@ -739,9 +740,9 @@ export type PayablesVoidOutput = {
|
|
|
739
740
|
};
|
|
740
741
|
export interface PayablesWriteOffInput {
|
|
741
742
|
lineAllocations?: unknown[] | null;
|
|
742
|
-
payableResource:
|
|
743
|
+
payableResource: ResourceKeyWith<"payable">;
|
|
743
744
|
payableRecord: string;
|
|
744
|
-
adjustmentResource:
|
|
745
|
+
adjustmentResource: ResourceKeyWith<"payable_adjustment">;
|
|
745
746
|
amount?: {
|
|
746
747
|
amount: number;
|
|
747
748
|
currency: string;
|
|
@@ -752,7 +753,7 @@ export interface PayablesWriteOffInput {
|
|
|
752
753
|
}
|
|
753
754
|
export type PayablesWriteOffOutput = Record<string, unknown>;
|
|
754
755
|
export interface PaymentCreateManualInput {
|
|
755
|
-
resource:
|
|
756
|
+
resource: ResourceKeyWith<"payment">;
|
|
756
757
|
payableRecord: string;
|
|
757
758
|
amount: {
|
|
758
759
|
amount: number;
|
|
@@ -765,7 +766,7 @@ export interface PaymentCreateManualInput {
|
|
|
765
766
|
}
|
|
766
767
|
export type PaymentCreateManualOutput = Record<string, unknown>;
|
|
767
768
|
export interface PaymentsChargeInput {
|
|
768
|
-
payableResource:
|
|
769
|
+
payableResource: ResourceKeyWith<"payable">;
|
|
769
770
|
payableRecord: string;
|
|
770
771
|
amount?: {
|
|
771
772
|
amount: number;
|
|
@@ -778,7 +779,7 @@ export interface PaymentsChargeInput {
|
|
|
778
779
|
}
|
|
779
780
|
export type PaymentsChargeOutput = Record<string, unknown>;
|
|
780
781
|
export interface PaymentsCheckoutInput {
|
|
781
|
-
payableResource:
|
|
782
|
+
payableResource: ResourceKeyWith<"payable">;
|
|
782
783
|
payableRecord: string;
|
|
783
784
|
successUrl: string;
|
|
784
785
|
cancelUrl?: string | null;
|
|
@@ -790,7 +791,7 @@ export type PaymentsCheckoutOutput = {
|
|
|
790
791
|
[key: string]: unknown;
|
|
791
792
|
};
|
|
792
793
|
export interface PaymentsConfirmInput {
|
|
793
|
-
payableResource:
|
|
794
|
+
payableResource: ResourceKeyWith<"payable">;
|
|
794
795
|
payableRecord: string;
|
|
795
796
|
confirmationTokenId?: string | null;
|
|
796
797
|
paymentMethodId?: string | null;
|
|
@@ -816,7 +817,7 @@ export type PaymentsConfirmOutput = {
|
|
|
816
817
|
[key: string]: unknown;
|
|
817
818
|
};
|
|
818
819
|
export interface PaymentsRefundInput {
|
|
819
|
-
resource:
|
|
820
|
+
resource: ResourceKeyWith<"payment">;
|
|
820
821
|
record: string;
|
|
821
822
|
amount?: {
|
|
822
823
|
amount: number;
|
|
@@ -902,7 +903,7 @@ export interface SmsSendNotificationInput {
|
|
|
902
903
|
}
|
|
903
904
|
export type SmsSendNotificationOutput = Record<string, unknown>;
|
|
904
905
|
export interface SubscriptionsActivateInput {
|
|
905
|
-
subscriptionResource:
|
|
906
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
906
907
|
subscriptionRecord: string;
|
|
907
908
|
}
|
|
908
909
|
export type SubscriptionsActivateOutput = {
|
|
@@ -910,7 +911,7 @@ export type SubscriptionsActivateOutput = {
|
|
|
910
911
|
[key: string]: unknown;
|
|
911
912
|
};
|
|
912
913
|
export interface SubscriptionsCancelInput {
|
|
913
|
-
subscriptionResource:
|
|
914
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
914
915
|
subscriptionRecord: string;
|
|
915
916
|
atPeriodEnd?: boolean | null;
|
|
916
917
|
}
|
|
@@ -919,7 +920,7 @@ export type SubscriptionsCancelOutput = {
|
|
|
919
920
|
[key: string]: unknown;
|
|
920
921
|
};
|
|
921
922
|
export interface SubscriptionsChangeItemsInput {
|
|
922
|
-
subscriptionResource:
|
|
923
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
923
924
|
subscriptionRecord: string;
|
|
924
925
|
items: Array<{
|
|
925
926
|
price_record_id?: string;
|
|
@@ -1100,7 +1101,7 @@ export type SubscriptionsChangeItemsOutput = {
|
|
|
1100
1101
|
[key: string]: unknown;
|
|
1101
1102
|
};
|
|
1102
1103
|
export interface SubscriptionsCreateInput {
|
|
1103
|
-
subscriptionResource:
|
|
1104
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1104
1105
|
accountingEntity?: string | null;
|
|
1105
1106
|
payerRecord: string;
|
|
1106
1107
|
priceRecordIds?: Array<string> | null;
|
|
@@ -1146,7 +1147,7 @@ export type SubscriptionsCreateOutput = {
|
|
|
1146
1147
|
[key: string]: unknown;
|
|
1147
1148
|
};
|
|
1148
1149
|
export interface SubscriptionsGenerateInvoiceInput {
|
|
1149
|
-
subscriptionResource:
|
|
1150
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1150
1151
|
subscriptionRecord: string;
|
|
1151
1152
|
}
|
|
1152
1153
|
export type SubscriptionsGenerateInvoiceOutput = {
|
|
@@ -1158,7 +1159,7 @@ export type SubscriptionsGenerateInvoiceOutput = {
|
|
|
1158
1159
|
[key: string]: unknown;
|
|
1159
1160
|
};
|
|
1160
1161
|
export interface SubscriptionsPauseInput {
|
|
1161
|
-
subscriptionResource:
|
|
1162
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1162
1163
|
subscriptionRecord: string;
|
|
1163
1164
|
}
|
|
1164
1165
|
export type SubscriptionsPauseOutput = {
|
|
@@ -1166,7 +1167,7 @@ export type SubscriptionsPauseOutput = {
|
|
|
1166
1167
|
[key: string]: unknown;
|
|
1167
1168
|
};
|
|
1168
1169
|
export interface SubscriptionsPreviewInput {
|
|
1169
|
-
subscriptionResource:
|
|
1170
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1170
1171
|
priceRecordIds?: Array<string> | null;
|
|
1171
1172
|
items?: Array<{
|
|
1172
1173
|
price_record_id?: string;
|
|
@@ -1347,7 +1348,7 @@ export type SubscriptionsPreviewOutput = {
|
|
|
1347
1348
|
[key: string]: unknown;
|
|
1348
1349
|
};
|
|
1349
1350
|
export interface SubscriptionsPreviewChangeInput {
|
|
1350
|
-
subscriptionResource:
|
|
1351
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1351
1352
|
subscriptionRecord: string;
|
|
1352
1353
|
items: Array<{
|
|
1353
1354
|
price_record_id?: string;
|
|
@@ -1521,7 +1522,7 @@ export type SubscriptionsPreviewChangeOutput = {
|
|
|
1521
1522
|
[key: string]: unknown;
|
|
1522
1523
|
};
|
|
1523
1524
|
export interface SubscriptionsResumeInput {
|
|
1524
|
-
subscriptionResource:
|
|
1525
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1525
1526
|
subscriptionRecord: string;
|
|
1526
1527
|
}
|
|
1527
1528
|
export type SubscriptionsResumeOutput = {
|
|
@@ -1529,7 +1530,7 @@ export type SubscriptionsResumeOutput = {
|
|
|
1529
1530
|
[key: string]: unknown;
|
|
1530
1531
|
};
|
|
1531
1532
|
export interface SubscriptionsSetUpcomingItemsInput {
|
|
1532
|
-
subscriptionResource:
|
|
1533
|
+
subscriptionResource: ResourceKeyWith<"subscription">;
|
|
1533
1534
|
subscriptionRecord: string;
|
|
1534
1535
|
desiredPriceRecordIds?: Array<string> | null;
|
|
1535
1536
|
items?: Array<{
|
|
@@ -1804,7 +1805,7 @@ export interface WorkflowRunInput {
|
|
|
1804
1805
|
[key: string]: unknown;
|
|
1805
1806
|
};
|
|
1806
1807
|
input?: Record<string, unknown> | null;
|
|
1807
|
-
runAsResource?:
|
|
1808
|
+
runAsResource?: ResourceKeyWith<"authenticatable"> | null;
|
|
1808
1809
|
runAsRecord?: string | null;
|
|
1809
1810
|
executionMode?: "async" | "sync" | null;
|
|
1810
1811
|
}
|
|
@@ -36,7 +36,7 @@ export declare const notification: {
|
|
|
36
36
|
sendBulkNotifications: <T extends NotificationTypeKey, R extends ResourceKey>(input: Omit<NotificationInput<NotificationSendBulkNotificationsInput, T>, "resource"> & {
|
|
37
37
|
resource: R;
|
|
38
38
|
}) => Promise<NotificationSendBulkNotificationsOutput>;
|
|
39
|
-
setConsent: <R extends
|
|
39
|
+
setConsent: <R extends NotificationSetConsentInput["resource"]>(input: Omit<NotificationSetConsentInput, "resource"> & {
|
|
40
40
|
resource: R;
|
|
41
41
|
}) => Promise<NotificationSetConsentOutput>;
|
|
42
42
|
send: (input: import("./index").NotificationSendInput) => Promise<import("./index").NotificationSendOutput>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ResourceKeyWith } from './data';
|
|
1
2
|
import type { ScriptHostContext } from './index';
|
|
2
3
|
import { type InferInput, type InputFieldSpec, type InputSchema, type InputShape } from './input';
|
|
3
4
|
export interface Identity {
|
|
4
5
|
id: string;
|
|
5
|
-
|
|
6
|
+
/** The identity's resource has the Authenticatable capability. */
|
|
7
|
+
resourceId: ResourceKeyWith<'authenticatable'>;
|
|
6
8
|
email: string | null;
|
|
7
9
|
name: string | null;
|
|
8
10
|
permissions: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diagonal-hq/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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": {
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"bin/diagonal.mjs",
|
|
31
31
|
"dist/cli.mjs",
|
|
32
32
|
"dist/index.js",
|
|
33
|
+
"dist/fields.generated.js",
|
|
33
34
|
"dist/index.d.ts",
|
|
35
|
+
"dist/fields.generated.d.ts",
|
|
36
|
+
"dist/capabilities.generated.d.ts",
|
|
34
37
|
"dist/globals.d.ts",
|
|
35
38
|
"dist/sdk-contract.d.ts",
|
|
36
39
|
"dist/workflow",
|