attio 0.0.1-experimental.20250821.2 → 0.0.1-experimental.20250825
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/lib/client/alert.d.ts +29 -0
- package/lib/client/alert.d.ts.map +1 -1
- package/lib/client/app.d.ts +208 -0
- package/lib/client/app.d.ts.map +1 -0
- package/lib/client/{workflow/schema-utils/array.js → app.js} +1 -1
- package/lib/client/app.js.map +1 -0
- package/lib/client/bulk-record-action.d.ts +22 -0
- package/lib/client/bulk-record-action.d.ts.map +1 -1
- package/lib/client/call-recording-insight-text-selection-action.d.ts +18 -0
- package/lib/client/call-recording-insight-text-selection-action.d.ts.map +1 -1
- package/lib/client/call-recording-summary-text-selection-action.d.ts +18 -0
- package/lib/client/call-recording-summary-text-selection-action.d.ts.map +1 -1
- package/lib/client/call-recording-transcript-text-selection-action.d.ts +26 -0
- package/lib/client/call-recording-transcript-text-selection-action.d.ts.map +1 -1
- package/lib/client/components/avatar.d.ts +24 -0
- package/lib/client/components/avatar.d.ts.map +1 -1
- package/lib/client/components/button.d.ts +28 -0
- package/lib/client/components/button.d.ts.map +1 -1
- package/lib/client/components/column.d.ts +8 -0
- package/lib/client/components/column.d.ts.map +1 -1
- package/lib/client/components/combobox.d.ts +57 -0
- package/lib/client/components/combobox.d.ts.map +1 -1
- package/lib/client/components/dialog-list.d.ts +37 -0
- package/lib/client/components/dialog-list.d.ts.map +1 -1
- package/lib/client/components/divider.d.ts +3 -0
- package/lib/client/components/divider.d.ts.map +1 -1
- package/lib/client/components/icon.d.ts +9 -0
- package/lib/client/components/icon.d.ts.map +1 -0
- package/lib/client/{workflow/block-config/config-schema/array.js → components/icon.js} +1 -1
- package/lib/client/components/icon.js.map +1 -0
- package/lib/client/components/index.d.ts +1 -0
- package/lib/client/components/index.d.ts.map +1 -1
- package/lib/client/components/index.js +3 -1
- package/lib/client/components/index.js.map +1 -1
- package/lib/client/components/json.d.ts +3 -0
- package/lib/client/components/json.d.ts.map +1 -1
- package/lib/client/components/keyboard-key.d.ts +7 -1
- package/lib/client/components/keyboard-key.d.ts.map +1 -1
- package/lib/client/components/link.d.ts +9 -0
- package/lib/client/components/link.d.ts.map +1 -1
- package/lib/client/components/row.d.ts +13 -0
- package/lib/client/components/row.d.ts.map +1 -1
- package/lib/client/components/section.d.ts +11 -0
- package/lib/client/components/section.d.ts.map +1 -1
- package/lib/client/components/status-badge.d.ts +6 -0
- package/lib/client/components/status-badge.d.ts.map +1 -1
- package/lib/client/components/text-block.d.ts +11 -0
- package/lib/client/components/text-block.d.ts.map +1 -1
- package/lib/client/components/typography.d.ts +13 -0
- package/lib/client/components/typography.d.ts.map +1 -1
- package/lib/client/components/widget-badge.d.ts +5 -0
- package/lib/client/components/widget-badge.d.ts.map +1 -1
- package/lib/client/components/widget-loading.d.ts +5 -0
- package/lib/client/components/widget-loading.d.ts.map +1 -1
- package/lib/client/components/widget-text-primary.d.ts +6 -0
- package/lib/client/components/widget-text-primary.d.ts.map +1 -1
- package/lib/client/components/widget-text-secondary.d.ts +6 -0
- package/lib/client/components/widget-text-secondary.d.ts.map +1 -1
- package/lib/client/components/widget-text-widget.d.ts +16 -0
- package/lib/client/components/widget-text-widget.d.ts.map +1 -1
- package/lib/client/components/widget-title.d.ts +6 -0
- package/lib/client/components/widget-title.d.ts.map +1 -1
- package/lib/client/components/widget.d.ts +4 -0
- package/lib/client/components/widget.d.ts.map +1 -1
- package/lib/client/confirm.d.ts +58 -0
- package/lib/client/confirm.d.ts.map +1 -1
- package/lib/client/forms/array.d.ts +12 -0
- package/lib/client/forms/array.d.ts.map +1 -1
- package/lib/client/forms/boolean.d.ts +12 -0
- package/lib/client/forms/boolean.d.ts.map +1 -1
- package/lib/client/forms/number.d.ts +24 -0
- package/lib/client/forms/number.d.ts.map +1 -1
- package/lib/client/forms/string.d.ts +47 -0
- package/lib/client/forms/string.d.ts.map +1 -1
- package/lib/client/forms/value.d.ts +8 -0
- package/lib/client/forms/value.d.ts.map +1 -1
- package/lib/client/hooks/use-async-cache.d.ts +62 -0
- package/lib/client/hooks/use-async-cache.d.ts.map +1 -1
- package/lib/client/hooks/use-form.d.ts +237 -1
- package/lib/client/hooks/use-form.d.ts.map +1 -1
- package/lib/client/hooks/use-query.d.ts +45 -0
- package/lib/client/hooks/use-query.d.ts.map +1 -1
- package/lib/client/hooks/use-record.d.ts +9 -0
- package/lib/client/hooks/use-record.d.ts.map +1 -1
- package/lib/client/hooks/use-records.d.ts +9 -0
- package/lib/client/hooks/use-records.d.ts.map +1 -1
- package/lib/client/hooks/use-workspace.d.ts +9 -0
- package/lib/client/hooks/use-workspace.d.ts.map +1 -1
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +1 -0
- package/lib/client/index.js.map +1 -1
- package/lib/client/record-action.d.ts +22 -0
- package/lib/client/record-action.d.ts.map +1 -1
- package/lib/client/record-widget.d.ts +24 -0
- package/lib/client/record-widget.d.ts.map +1 -1
- package/lib/client/run-query.d.ts +48 -1
- package/lib/client/run-query.d.ts.map +1 -1
- package/lib/client/show-dialog.d.ts +23 -0
- package/lib/client/show-dialog.d.ts.map +1 -1
- package/lib/client/show-iframe.d.ts +63 -0
- package/lib/client/show-iframe.d.ts.map +1 -1
- package/lib/client/show-toast.d.ts +48 -0
- package/lib/client/show-toast.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/array-node.d.ts +10 -0
- package/lib/client/workflow/block-config/config-schema/array-node.d.ts.map +1 -0
- package/lib/client/workflow/block-config/config-schema/{struct.js → array-node.js} +1 -1
- package/lib/client/workflow/block-config/config-schema/array-node.js.map +1 -0
- package/lib/client/workflow/block-config/config-schema/attio-record.d.ts +8 -0
- package/lib/client/workflow/block-config/config-schema/attio-record.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/attio-select.d.ts +8 -0
- package/lib/client/workflow/block-config/config-schema/attio-select.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/boolean-node.d.ts +8 -0
- package/lib/client/workflow/block-config/config-schema/boolean-node.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/friendly-node.d.ts +5 -2
- package/lib/client/workflow/block-config/config-schema/friendly-node.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/index.d.ts +3 -3
- package/lib/client/workflow/block-config/config-schema/index.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/index.js +4 -4
- package/lib/client/workflow/block-config/config-schema/index.js.map +1 -1
- package/lib/client/workflow/block-config/config-schema/node.d.ts +14 -5
- package/lib/client/workflow/block-config/config-schema/node.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/number-node.d.ts +8 -0
- package/lib/client/workflow/block-config/config-schema/number-node.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/path.d.ts +9 -2
- package/lib/client/workflow/block-config/config-schema/path.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/string-node.d.ts +8 -0
- package/lib/client/workflow/block-config/config-schema/string-node.d.ts.map +1 -1
- package/lib/client/workflow/block-config/config-schema/struct-node.d.ts +12 -0
- package/lib/client/workflow/block-config/config-schema/struct-node.d.ts.map +1 -0
- package/lib/client/workflow/block-config/config-schema/struct-node.js +3 -0
- package/lib/client/workflow/block-config/config-schema/struct-node.js.map +1 -0
- package/lib/client/workflow/block-config/inputs/attio-record.d.ts +5 -2
- package/lib/client/workflow/block-config/inputs/attio-record.d.ts.map +1 -1
- package/lib/client/workflow/block-config/inputs/attio-select.d.ts +5 -2
- package/lib/client/workflow/block-config/inputs/attio-select.d.ts.map +1 -1
- package/lib/client/workflow/block-config/inputs/get-inputs.d.ts +5 -0
- package/lib/client/workflow/block-config/inputs/get-inputs.d.ts.map +1 -1
- package/lib/client/workflow/block-config/inputs/number.d.ts +3 -0
- package/lib/client/workflow/block-config/inputs/number.d.ts.map +1 -1
- package/lib/client/workflow/block-config/inputs/text.d.ts +3 -0
- package/lib/client/workflow/block-config/inputs/text.d.ts.map +1 -1
- package/lib/client/workflow/index.d.ts +12 -0
- package/lib/client/workflow/index.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/{array.d.ts → array-node.d.ts} +3 -3
- package/lib/client/workflow/schema-utils/array-node.d.ts.map +1 -0
- package/lib/client/workflow/schema-utils/{struct.js → array-node.js} +1 -1
- package/lib/client/workflow/schema-utils/array-node.js.map +1 -0
- package/lib/client/workflow/schema-utils/base-node.d.ts +3 -0
- package/lib/client/workflow/schema-utils/base-node.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/base-node.js +3 -0
- package/lib/client/workflow/schema-utils/base-node.js.map +1 -1
- package/lib/client/workflow/schema-utils/friendly.d.ts +7 -3
- package/lib/client/workflow/schema-utils/friendly.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/index.d.ts +5 -2
- package/lib/client/workflow/schema-utils/index.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/index.js +3 -0
- package/lib/client/workflow/schema-utils/index.js.map +1 -1
- package/lib/client/workflow/schema-utils/normalize.d.ts +7 -4
- package/lib/client/workflow/schema-utils/normalize.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/path.d.ts +12 -5
- package/lib/client/workflow/schema-utils/path.d.ts.map +1 -1
- package/lib/client/workflow/schema-utils/{struct.d.ts → struct-node.d.ts} +3 -3
- package/lib/client/workflow/schema-utils/struct-node.d.ts.map +1 -0
- package/lib/client/workflow/schema-utils/struct-node.js +3 -0
- package/lib/client/workflow/schema-utils/struct-node.js.map +1 -0
- package/lib/client/workflow-block.d.ts +2 -2
- package/lib/client/workflow-block.d.ts.map +1 -1
- package/lib/server/attio-fetch.d.ts +38 -0
- package/lib/server/attio-fetch.d.ts.map +1 -1
- package/lib/server/connections.d.ts +5 -0
- package/lib/server/connections.d.ts.map +1 -1
- package/lib/server/experimental/index.d.ts +1 -0
- package/lib/server/experimental/index.d.ts.map +1 -1
- package/lib/server/experimental/index.js +1 -0
- package/lib/server/experimental/index.js.map +1 -1
- package/lib/server/experimental/kv-store.d.ts +26 -0
- package/lib/server/experimental/kv-store.d.ts.map +1 -1
- package/lib/server/webhook-handlers.d.ts +11 -0
- package/lib/server/webhook-handlers.d.ts.map +1 -1
- package/lib/shared/errors.d.ts +12 -0
- package/lib/shared/errors.d.ts.map +1 -1
- package/lib/template/src/hello-world-action.tsx +1 -1
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/util/find-surface-exports/parse-file-exports.js +2 -2
- package/lib/util/surfaces.js +1 -1
- package/lib/utils/prettify.d.ts +15 -0
- package/lib/utils/prettify.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/client/workflow/block-config/config-schema/array.d.ts +0 -5
- package/lib/client/workflow/block-config/config-schema/array.d.ts.map +0 -1
- package/lib/client/workflow/block-config/config-schema/array.js.map +0 -1
- package/lib/client/workflow/block-config/config-schema/struct.d.ts +0 -7
- package/lib/client/workflow/block-config/config-schema/struct.d.ts.map +0 -1
- package/lib/client/workflow/block-config/config-schema/struct.js.map +0 -1
- package/lib/client/workflow/schema-utils/array.d.ts.map +0 -1
- package/lib/client/workflow/schema-utils/array.js.map +0 -1
- package/lib/client/workflow/schema-utils/struct.d.ts.map +0 -1
- package/lib/client/workflow/schema-utils/struct.js.map +0 -1
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
import type { FormValue } from "./value";
|
|
2
|
+
/**
|
|
3
|
+
* A number form value.
|
|
4
|
+
*/
|
|
2
5
|
export interface FormNumber<TOptional extends boolean = false> extends FormValue {
|
|
3
6
|
type: "number";
|
|
7
|
+
/**
|
|
8
|
+
* Whether this number is optional, i.e. allows `undefined` values.
|
|
9
|
+
*/
|
|
4
10
|
isOptional: TOptional;
|
|
11
|
+
/**
|
|
12
|
+
* Make this number optional, i.e. allow `undefined` values.
|
|
13
|
+
*/
|
|
5
14
|
optional(): FormNumber<true>;
|
|
15
|
+
/**
|
|
16
|
+
* Set the default value of this number. The default value will be returned if the user
|
|
17
|
+
* doesn't provide a value.
|
|
18
|
+
*
|
|
19
|
+
* NOTE that this is not the same as an initial value!
|
|
20
|
+
*/
|
|
6
21
|
default(value: number): FormNumber<TOptional>;
|
|
22
|
+
/**
|
|
23
|
+
* Set the maximum value of this number.
|
|
24
|
+
*/
|
|
7
25
|
max(max: number): FormNumber<TOptional>;
|
|
26
|
+
/**
|
|
27
|
+
* Set the minimum value of this number.
|
|
28
|
+
*/
|
|
8
29
|
min(min: number): FormNumber<TOptional>;
|
|
9
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new number form value.
|
|
33
|
+
*/
|
|
10
34
|
export declare function number(): FormNumber<false>;
|
|
11
35
|
//# sourceMappingURL=number.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../src/client/forms/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../src/client/forms/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;AAEtC;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,SAAS,SAAS,OAAO,GAAG,KAAK,CAAE,SAAQ,SAAS;IAC5E,IAAI,EAAE,QAAQ,CAAA;IAEd;;OAEG;IACH,UAAU,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE7C;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAEvC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;CAC1C;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -1,18 +1,65 @@
|
|
|
1
1
|
import type { FormValue } from "./value";
|
|
2
|
+
/**
|
|
3
|
+
* A string form value.
|
|
4
|
+
*/
|
|
2
5
|
export interface FormString<TOptional extends boolean = false> extends FormValue {
|
|
3
6
|
type: "string";
|
|
7
|
+
/**
|
|
8
|
+
* Whether or not this string is multiline.
|
|
9
|
+
*
|
|
10
|
+
* Multiline strings are rendered as textarea fields.
|
|
11
|
+
*/
|
|
4
12
|
isMultiline: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether this string is optional, i.e. allows `""` or `undefined` values.
|
|
15
|
+
*/
|
|
5
16
|
isOptional: TOptional;
|
|
17
|
+
/**
|
|
18
|
+
* Whether this string is required to be a valid URL.
|
|
19
|
+
*/
|
|
6
20
|
isUrl: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Set the default value of this string. The default value will be returned if the user
|
|
23
|
+
* doesn't provide a value.
|
|
24
|
+
*
|
|
25
|
+
* NOTE that this is not the same as an initial value!
|
|
26
|
+
*/
|
|
7
27
|
default(value: string): FormString<TOptional>;
|
|
28
|
+
/**
|
|
29
|
+
* Make this string optional, i.e. allow `""` or `undefined` values.
|
|
30
|
+
*/
|
|
8
31
|
optional(): FormString<true>;
|
|
32
|
+
/**
|
|
33
|
+
* Make this string multiline, i.e. render as textarea field.
|
|
34
|
+
*/
|
|
9
35
|
multiline(): FormString<TOptional>;
|
|
36
|
+
/**
|
|
37
|
+
* Set the maximum length of this string.
|
|
38
|
+
*/
|
|
10
39
|
maxLength(length: number): FormString<TOptional>;
|
|
40
|
+
/**
|
|
41
|
+
* Set the minimum length of this string.
|
|
42
|
+
*/
|
|
11
43
|
minLength(length: number): FormString<TOptional>;
|
|
44
|
+
/**
|
|
45
|
+
* Ensure that this string is a valid URL.
|
|
46
|
+
*
|
|
47
|
+
* A URL without a protocol, e.g. "attio.com" will pass validation, but will be
|
|
48
|
+
* given to `onSubmit` as "https://attio.com".
|
|
49
|
+
*
|
|
50
|
+
* @param options - The options for URL validation.
|
|
51
|
+
* @param options.protocol - The protocol regex to use for URL validation. If not provided,
|
|
52
|
+
* the default is `https?`.
|
|
53
|
+
* @param options.message - The message to use for URL validation errors. If not provided,
|
|
54
|
+
* the default is `Must be a valid URL`.
|
|
55
|
+
*/
|
|
12
56
|
url(options?: {
|
|
13
57
|
protocol: RegExp;
|
|
14
58
|
message?: string;
|
|
15
59
|
}): FormString<TOptional>;
|
|
16
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a new string form value.
|
|
63
|
+
*/
|
|
17
64
|
export declare function string(): FormString<false>;
|
|
18
65
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/client/forms/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/client/forms/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;AAEtC;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,SAAS,SAAS,OAAO,GAAG,KAAK,CAAE,SAAQ,SAAS;IAC5E,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;OAEG;IACH,UAAU,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;IAEd;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE7C;;OAEG;IACH,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;IAE5B;;OAEG;IACH,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,CAAA;IAElC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAEhD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,OAAO,CAAC,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;CAC7E;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An opaque type for form values.
|
|
3
|
+
*/
|
|
1
4
|
export interface FormValue {
|
|
2
5
|
readonly __brand: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Control how the form value is serialized to a JSON object.
|
|
8
|
+
*
|
|
9
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior
|
|
10
|
+
*/
|
|
3
11
|
toJSON(): Readonly<Record<string, unknown>>;
|
|
4
12
|
}
|
|
5
13
|
//# sourceMappingURL=value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../../src/client/forms/value.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../../src/client/forms/value.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAA;IAE/B;;;;OAIG;IACH,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAC9C"}
|
|
@@ -1,7 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An async function that returns data.
|
|
3
|
+
*/
|
|
1
4
|
export type AsyncFunction<Input extends Array<any>, Output> = (...args: Input) => Promise<Output>;
|
|
5
|
+
/**
|
|
6
|
+
* A type-safe configuration object for multiple loaders.
|
|
7
|
+
*
|
|
8
|
+
* The key is used to cache the result of the loader.
|
|
9
|
+
* The value is a loader that takes an array of arguments and returns a promise.
|
|
10
|
+
*/
|
|
2
11
|
export interface AsyncCacheConfig {
|
|
3
12
|
[K: string]: AsyncFunction<Array<any>, any> | [AsyncFunction<Array<any>, any>, ...Array<any>];
|
|
4
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* A hook that returns, and caches, the results of calling one or more async functions,
|
|
16
|
+
* typically to load data from a third party via server functions.
|
|
17
|
+
*
|
|
18
|
+
* The component it is used in will suspend until ALL async functions have resolved.
|
|
19
|
+
*
|
|
20
|
+
* ## EXAMPLE USAGE
|
|
21
|
+
*
|
|
22
|
+
* ----
|
|
23
|
+
* ```ts
|
|
24
|
+
* // load-widgets.server.ts
|
|
25
|
+
* export default async function loadWidgets() : Promise<Array<Widget>> {
|
|
26
|
+
* // fetch widgets from somewhere
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
* ----
|
|
30
|
+
* ```ts
|
|
31
|
+
* // load-sprockets.server.ts
|
|
32
|
+
* export default async function loadSprockets(
|
|
33
|
+
* material: Material,
|
|
34
|
+
* max?: number
|
|
35
|
+
* ): Promise<Array<Sprocket>> {
|
|
36
|
+
* // fetch sprockets from somewhere
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
* ----
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { useAsyncCache } from "attio/client"
|
|
42
|
+
*
|
|
43
|
+
* import loadWidgets from "./load-widgets.server.ts"
|
|
44
|
+
* import loadSprockets from "./load-sprockets.server.ts"
|
|
45
|
+
*
|
|
46
|
+
* ...
|
|
47
|
+
*
|
|
48
|
+
* // inside component:
|
|
49
|
+
*
|
|
50
|
+
* const results = useAsyncCache({
|
|
51
|
+
* // loadWidgets takes zero parameters and can thus be called without an array
|
|
52
|
+
* widgets: loadWidgets,
|
|
53
|
+
* // loadSprockets takes a `material` parameter, so we call it like this
|
|
54
|
+
* ironSprockets: [loadSprockets, "iron"],
|
|
55
|
+
* copperSprockets: [loadSprockets, "copper", 42],
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* const { widgets, ironSprockets, copperSprockets } = results.values
|
|
59
|
+
*
|
|
60
|
+
* ...
|
|
61
|
+
*
|
|
62
|
+
* // inside an event handler, perhaps, to refetch _only_ the iron sprockets
|
|
63
|
+
* results.invalidate("ironSprockets")
|
|
64
|
+
* ```
|
|
65
|
+
* ----
|
|
66
|
+
*/
|
|
5
67
|
export declare function useAsyncCache<Config extends AsyncCacheConfig>(config: Config): {
|
|
6
68
|
values: {
|
|
7
69
|
[K in keyof Config]: Config[K] extends AsyncFunction<any, infer Output> ? Output : Config[K] extends [AsyncFunction<infer Input, infer Output>, ...infer Args] ? Args extends Input ? Output : never : never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-async-cache.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-async-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-async-cache.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-async-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC7B,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;CAChG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,MAAM,SAAS,gBAAgB,EACjE,MAAM,EAAE,MAAM,GACf;IACC,MAAM,EAAE;SACH,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC,GACjE,MAAM,GACN,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,GACzE,IAAI,SAAS,KAAK,GACd,MAAM,GACN,KAAK,GACT,KAAK;KAChB,CAAA;IACD,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;CAC5D,CAAA"}
|
|
@@ -3,78 +3,228 @@ import type { DecoratedComboboxOption, DecoratedComboboxOptionsProvider, PlainCo
|
|
|
3
3
|
import type { PathTo, ValueOf } from "../forms/path";
|
|
4
4
|
import type { FormValue } from "../forms/value";
|
|
5
5
|
export type FormSchema = Record<string, FormValue>;
|
|
6
|
+
/**
|
|
7
|
+
* Recursive type for validation errors that can be nested.
|
|
8
|
+
* Each field can either be a string error message or a nested object of errors.
|
|
9
|
+
*/
|
|
6
10
|
export type ValidationErrors<T> = Partial<{
|
|
7
11
|
[K in keyof T]: T[K] extends object ? ValidationErrors<T[K]> : string;
|
|
8
12
|
}>;
|
|
13
|
+
/**
|
|
14
|
+
* A <Form> component that must wrap all the fields and provide a submit handler.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Form onSubmit={(values) => {
|
|
19
|
+
* console.log(values)
|
|
20
|
+
* }}>
|
|
21
|
+
* <TextInput name="name" label="Name" />
|
|
22
|
+
* <NumberInput name="age" label="Age" />
|
|
23
|
+
* <Checkbox name="isActive" label="Is Active" />
|
|
24
|
+
* <Toggle name="isExpress" label="Is Express" />
|
|
25
|
+
* <SubmitButton label="Submit" />
|
|
26
|
+
* </Form>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
9
29
|
type Form<TSchema extends FormSchema> = (props: {
|
|
30
|
+
/** The contents of the form, including layout and input components */
|
|
10
31
|
children: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* The function to call when the form is submitted.
|
|
34
|
+
*
|
|
35
|
+
* `onSubmit` will NOT be called if there are validation errors.
|
|
36
|
+
*/
|
|
11
37
|
onSubmit: (values: ValueOf<TSchema>) => void | Promise<void>;
|
|
12
38
|
}) => JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* A text input field.
|
|
41
|
+
*/
|
|
13
42
|
type TextInput<TSchema extends FormSchema> = (props: {
|
|
43
|
+
/** The type of the input field. Defaults to "text". */
|
|
14
44
|
type?: "text" | "email" | "password" | "tel" | "url";
|
|
45
|
+
/** The label of the input field */
|
|
15
46
|
label: string;
|
|
47
|
+
/**
|
|
48
|
+
* The path to the value of the input field, e.g. `"name"` or `"address.street"`
|
|
49
|
+
* @deprecated Use `name` instead
|
|
50
|
+
**/
|
|
16
51
|
data?: PathTo<TSchema, "string">;
|
|
52
|
+
/** The path to the value of the input field, e.g. `"name"` or `"address.street"` */
|
|
17
53
|
name: PathTo<TSchema, "string">;
|
|
54
|
+
/** The optional placeholder text of the input field */
|
|
18
55
|
placeholder?: string;
|
|
56
|
+
/** Whether the input field is disabled */
|
|
19
57
|
disabled?: boolean;
|
|
20
58
|
}) => JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* A number input field.
|
|
61
|
+
*/
|
|
21
62
|
type NumberInput<TSchema extends FormSchema> = (props: {
|
|
63
|
+
/** The label of the input field */
|
|
22
64
|
label: string;
|
|
65
|
+
/**
|
|
66
|
+
* The path to the value of the input field, e.g. `"age"` or `"shipping.cost"`
|
|
67
|
+
* @deprecated Use `name` instead
|
|
68
|
+
**/
|
|
23
69
|
data?: PathTo<TSchema, "number">;
|
|
70
|
+
/** The path to the value of the input field, e.g. `"age"` or `"shipping.cost"` */
|
|
24
71
|
name: PathTo<TSchema, "number">;
|
|
72
|
+
/** The optional placeholder text of the input field */
|
|
25
73
|
placeholder?: string;
|
|
74
|
+
/** Whether the input field is disabled */
|
|
26
75
|
disabled?: boolean;
|
|
27
76
|
}) => JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* A rich text input field.
|
|
79
|
+
*/
|
|
28
80
|
type RichTextInput<TSchema extends FormSchema> = (props: {
|
|
81
|
+
/** The label of the input field */
|
|
29
82
|
label: string;
|
|
83
|
+
/** The path to the value of the input field, e.g. `"name"` or `"address.street"` */
|
|
30
84
|
name: PathTo<TSchema, "string">;
|
|
85
|
+
/** The optional placeholder text of the input field */
|
|
31
86
|
placeholder?: string;
|
|
87
|
+
/** Whether the input field is disabled */
|
|
32
88
|
disabled?: boolean;
|
|
33
89
|
}) => JSX.Element;
|
|
90
|
+
/**
|
|
91
|
+
* A checkbox input field.
|
|
92
|
+
*/
|
|
34
93
|
type Checkbox<TSchema extends FormSchema> = (props: {
|
|
94
|
+
/** The label of the input field */
|
|
35
95
|
label: string;
|
|
96
|
+
/**
|
|
97
|
+
* The path to the value of the input field, e.g. `"is_active"` or `"shipping.is_express"`
|
|
98
|
+
* @deprecated Use `name` instead
|
|
99
|
+
**/
|
|
36
100
|
data?: PathTo<TSchema, "boolean">;
|
|
101
|
+
/** The path to the value of the input field, e.g. `"is_active"` or `"shipping.is_express"` */
|
|
37
102
|
name: PathTo<TSchema, "boolean">;
|
|
103
|
+
/** Whether the input field is disabled */
|
|
38
104
|
disabled?: boolean;
|
|
39
105
|
}) => JSX.Element;
|
|
106
|
+
/**
|
|
107
|
+
* A toggle input field.
|
|
108
|
+
*/
|
|
40
109
|
type Toggle<TSchema extends FormSchema> = (props: {
|
|
110
|
+
/** The label of the input field */
|
|
41
111
|
label: string;
|
|
112
|
+
/**
|
|
113
|
+
* The path to the value of the input field, e.g. `"is_active"` or `"shipping.is_express"`
|
|
114
|
+
* @deprecated Use `name` instead
|
|
115
|
+
**/
|
|
42
116
|
data?: PathTo<TSchema, "boolean">;
|
|
117
|
+
/** The path to the value of the input field, e.g. `"is_active"` or `"shipping.is_express"` */
|
|
43
118
|
name: PathTo<TSchema, "boolean">;
|
|
119
|
+
/** Whether the input field is disabled */
|
|
44
120
|
disabled?: boolean;
|
|
45
121
|
}) => JSX.Element;
|
|
122
|
+
/**
|
|
123
|
+
* Base props common to all combobox variants.
|
|
124
|
+
*/
|
|
46
125
|
export interface BaseComboboxProps<TSchema extends FormSchema> {
|
|
126
|
+
/** The label of the combobox field */
|
|
47
127
|
label: string;
|
|
128
|
+
/**
|
|
129
|
+
* The path to the value of the combobox field, e.g. `"mode"` or `"shipping.method"`
|
|
130
|
+
* @deprecated Use `name` instead
|
|
131
|
+
**/
|
|
48
132
|
data?: PathTo<TSchema, "string">;
|
|
133
|
+
/** The path to the value of the combobox field, e.g. `"mode"` or `"shipping.method"` */
|
|
49
134
|
name: PathTo<TSchema, "string">;
|
|
135
|
+
/**
|
|
136
|
+
* The optional placeholder text for the search input
|
|
137
|
+
*
|
|
138
|
+
* @default "Search..."
|
|
139
|
+
*/
|
|
50
140
|
searchPlaceholder?: string;
|
|
141
|
+
/** Whether the combobox field is disabled */
|
|
51
142
|
disabled?: boolean;
|
|
52
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Props for decorated combobox variant.
|
|
146
|
+
*/
|
|
53
147
|
export interface DecoratedComboboxProps {
|
|
148
|
+
/**
|
|
149
|
+
* If decorated, the combobox will be require decorated options. Defaults to true.
|
|
150
|
+
*
|
|
151
|
+
* @deprecated This may change in the future.
|
|
152
|
+
*/
|
|
54
153
|
__experimental_decorated: true;
|
|
154
|
+
/**
|
|
155
|
+
* The options of the combobox field
|
|
156
|
+
*
|
|
157
|
+
* Either an array of options, or a provider that asynchronously fetches options.
|
|
158
|
+
*/
|
|
55
159
|
options: Array<DecoratedComboboxOption> | DecoratedComboboxOptionsProvider;
|
|
160
|
+
/**
|
|
161
|
+
* The optional placeholder text or option of the combobox field
|
|
162
|
+
**/
|
|
56
163
|
placeholder?: string | Omit<DecoratedComboboxOption, "value">;
|
|
57
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Props for plain combobox variant.
|
|
167
|
+
*/
|
|
58
168
|
export interface PlainComboboxProps {
|
|
169
|
+
/**
|
|
170
|
+
* If not decorated, the combobox will be plain. Defaults to false.
|
|
171
|
+
*
|
|
172
|
+
* @deprecated This may change in the future.
|
|
173
|
+
*/
|
|
59
174
|
__experimental_decorated?: false;
|
|
175
|
+
/**
|
|
176
|
+
* The options of the combobox field
|
|
177
|
+
*
|
|
178
|
+
* Either an array of options, or a provider that asynchronously fetches options.
|
|
179
|
+
*/
|
|
60
180
|
options: Array<PlainComboboxOption> | PlainComboboxOptionsProvider;
|
|
181
|
+
/**
|
|
182
|
+
* The optional placeholder text or option of the combobox field
|
|
183
|
+
**/
|
|
61
184
|
placeholder?: string;
|
|
62
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* A combobox input field.
|
|
188
|
+
*/
|
|
63
189
|
type Combobox<TSchema extends FormSchema> = (props: BaseComboboxProps<TSchema> & (DecoratedComboboxProps | PlainComboboxProps)) => JSX.Element;
|
|
190
|
+
/**
|
|
191
|
+
* A component used to render a collection of inputs.
|
|
192
|
+
*/
|
|
64
193
|
type Collection<TSchema extends FormSchema, TPath extends PathTo<TSchema, "array">> = (props: {
|
|
194
|
+
/** The label of the collection field */
|
|
65
195
|
label: string;
|
|
196
|
+
/**
|
|
197
|
+
* The path to the value of the collection field, e.g. `"items"` or `"shipping.items"`
|
|
198
|
+
* @deprecated Use `name` instead
|
|
199
|
+
**/
|
|
66
200
|
data?: TPath;
|
|
201
|
+
/** The path to the value of the collection field, e.g. `"items"` or `"shipping.items"` */
|
|
67
202
|
name: TPath;
|
|
203
|
+
/**
|
|
204
|
+
* A render prop that receives the path and index of one of the items and renders
|
|
205
|
+
* the inputs for that item
|
|
206
|
+
*/
|
|
68
207
|
children: (args: {
|
|
69
208
|
path: `${TPath}.${number}`;
|
|
70
209
|
index: number;
|
|
71
210
|
}) => React.ReactNode;
|
|
72
211
|
}) => JSX.Element;
|
|
212
|
+
/**
|
|
213
|
+
* A component used to group inputs in a collection together
|
|
214
|
+
*/
|
|
73
215
|
type CollectionItem = (props: {
|
|
216
|
+
/** The label of the collection item */
|
|
74
217
|
label: string;
|
|
218
|
+
/** The inputs of the collection item */
|
|
75
219
|
children: React.ReactNode;
|
|
76
220
|
}) => JSX.Element;
|
|
221
|
+
/**
|
|
222
|
+
* A submit button for the form.
|
|
223
|
+
*
|
|
224
|
+
* If the form is rendered inside a dialog, the submit button will be placed at the bottom of the dialog.
|
|
225
|
+
*/
|
|
77
226
|
type SubmitButton = (props: {
|
|
227
|
+
/** The label of the submit button */
|
|
78
228
|
label: string;
|
|
79
229
|
}) => JSX.Element;
|
|
80
230
|
export interface WithStateProps<TSchema extends FormSchema, TValues extends boolean = false, TSubmitting extends boolean = false, TErrors extends boolean = false> {
|
|
@@ -87,22 +237,108 @@ export interface WithStateProps<TSchema extends FormSchema, TValues extends bool
|
|
|
87
237
|
errors: TErrors extends true ? Record<string, string> : never;
|
|
88
238
|
}) => JSX.Element;
|
|
89
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* A component that provides the form state via a render prop.
|
|
242
|
+
*
|
|
243
|
+
* You may specifically request various parts of form state, such as
|
|
244
|
+
* `values`, `submitting`, and `errors`. This component will rerender
|
|
245
|
+
* whenever any of the values requested change.
|
|
246
|
+
*/
|
|
90
247
|
type WithState<TSchema extends FormSchema> = (props: WithStateProps<TSchema> | WithStateProps<TSchema, true> | WithStateProps<TSchema, boolean, true> | WithStateProps<TSchema, boolean, boolean, true>) => JSX.Element;
|
|
91
248
|
export interface FormApi<TSchema extends FormSchema> {
|
|
249
|
+
/**
|
|
250
|
+
* Submits the form.
|
|
251
|
+
*
|
|
252
|
+
* This will validate the form and call the `onSubmit` handler.
|
|
253
|
+
*/
|
|
92
254
|
submit: () => void;
|
|
255
|
+
/**
|
|
256
|
+
* Changes the value of a field.
|
|
257
|
+
*/
|
|
93
258
|
change: <TPath extends PathTo<TSchema, "string" | "number">>(path: TPath, value: ValueOf<TSchema>[TPath]) => void;
|
|
259
|
+
/**
|
|
260
|
+
* The <Form> component to wrap the fields of this form and provide a submit handler.
|
|
261
|
+
*/
|
|
94
262
|
Form: Form<TSchema>;
|
|
263
|
+
/**
|
|
264
|
+
* A text input field.
|
|
265
|
+
*/
|
|
95
266
|
TextInput: TextInput<TSchema>;
|
|
267
|
+
/**
|
|
268
|
+
* A number input field.
|
|
269
|
+
*/
|
|
96
270
|
NumberInput: NumberInput<TSchema>;
|
|
271
|
+
/**
|
|
272
|
+
* A rich text input field.
|
|
273
|
+
*/
|
|
97
274
|
Experimental_RichTextInput: RichTextInput<TSchema>;
|
|
275
|
+
/**
|
|
276
|
+
* A checkbox input field.
|
|
277
|
+
*/
|
|
98
278
|
Checkbox: Checkbox<TSchema>;
|
|
279
|
+
/**
|
|
280
|
+
* A toggle input field.
|
|
281
|
+
*/
|
|
99
282
|
Toggle: Toggle<TSchema>;
|
|
283
|
+
/**
|
|
284
|
+
* A combobox input field.
|
|
285
|
+
*/
|
|
100
286
|
Combobox: Combobox<TSchema>;
|
|
287
|
+
/**
|
|
288
|
+
* A component used to render a collection of inputs.
|
|
289
|
+
* @deprecated This is not fully built yet.
|
|
290
|
+
*/
|
|
101
291
|
Collection: Collection<TSchema, any>;
|
|
292
|
+
/**
|
|
293
|
+
* A component used to group inputs in a collection together.
|
|
294
|
+
* @deprecated This is not fully built yet.
|
|
295
|
+
*/
|
|
102
296
|
CollectionItem: CollectionItem;
|
|
297
|
+
/**
|
|
298
|
+
* A submit button for the form.
|
|
299
|
+
*/
|
|
103
300
|
SubmitButton: SubmitButton;
|
|
301
|
+
/**
|
|
302
|
+
* A component that provides the form state via a render prop.
|
|
303
|
+
*/
|
|
104
304
|
WithState: WithState<TSchema>;
|
|
105
305
|
}
|
|
106
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Creates a form API for a given schema and initial values.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```tsx
|
|
311
|
+
* const api = useForm({
|
|
312
|
+
* name: Forms.string(),
|
|
313
|
+
* age: Forms.number(),
|
|
314
|
+
* isActive: Forms.boolean(),
|
|
315
|
+
* isExpress: Forms.boolean(),
|
|
316
|
+
* }, {
|
|
317
|
+
* name: "John",
|
|
318
|
+
* age: 30,
|
|
319
|
+
* isActive: true,
|
|
320
|
+
* isExpress: false,
|
|
321
|
+
* });
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export declare function useForm<TSchema extends FormSchema>(schema: TSchema, initialValues: Partial<ValueOf<TSchema>>,
|
|
325
|
+
/**
|
|
326
|
+
* Optional function to validate the form.
|
|
327
|
+
*
|
|
328
|
+
* Errors should be returned as a record of field names to error messages.
|
|
329
|
+
* The keys must match the keys of the form schema.
|
|
330
|
+
*
|
|
331
|
+
* Errors can be nested for complex objects. e.g.
|
|
332
|
+
* ```ts
|
|
333
|
+
* {
|
|
334
|
+
* shipping: {
|
|
335
|
+
* street: "Street is required"
|
|
336
|
+
* }
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* Errors given here will be overridden by errors generated by the form schema.
|
|
341
|
+
*/
|
|
342
|
+
validate?: (values: ValueOf<TSchema>) => ValidationErrors<ValueOf<TSchema>>): FormApi<TSchema>;
|
|
107
343
|
export {};
|
|
108
344
|
//# sourceMappingURL=use-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,OAAO,CA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AO,CAAC,CAAA"}
|
|
@@ -1,3 +1,48 @@
|
|
|
1
1
|
import type { Query } from "../run-query";
|
|
2
|
+
/**
|
|
3
|
+
* A hook that runs a GraphQL query and returns the result.
|
|
4
|
+
*
|
|
5
|
+
* Your component will suspend until the query completes.
|
|
6
|
+
*
|
|
7
|
+
* If you import the query from a `.graphql` file, and run `attio dev`,
|
|
8
|
+
* your query variables and result will be strongly typed.
|
|
9
|
+
*
|
|
10
|
+
* ## EXAMPLE USAGE
|
|
11
|
+
*
|
|
12
|
+
* ----
|
|
13
|
+
* ```graphql
|
|
14
|
+
* # get-person.graphql
|
|
15
|
+
* query getPerson($id: String!) {
|
|
16
|
+
* workspace {
|
|
17
|
+
* person(id: $id) {
|
|
18
|
+
* name {
|
|
19
|
+
* first
|
|
20
|
+
* last
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* ----
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Component.tsx
|
|
29
|
+
* import { useQuery, useRecord } from "attio/client"
|
|
30
|
+
* import getPersonQuery from "./get-person.graphql"
|
|
31
|
+
*
|
|
32
|
+
* ...
|
|
33
|
+
*
|
|
34
|
+
* // in component:
|
|
35
|
+
* const { recordId } = useRecord()
|
|
36
|
+
* const result = useQuery(getPersonQuery, { id: recordId })
|
|
37
|
+
*
|
|
38
|
+
* const firstName : string | null = result.workspace?.person?.name?.first
|
|
39
|
+
* const lastName : string | null = result.workspace?.person?.name?.last
|
|
40
|
+
* ```
|
|
41
|
+
* ----
|
|
42
|
+
*
|
|
43
|
+
* @param query - The GraphQL query to run.
|
|
44
|
+
* @param variableValues - The variables to pass to the query.
|
|
45
|
+
* @returns The result of the query.
|
|
46
|
+
*/
|
|
2
47
|
export declare function useQuery<Variables extends Record<string, any> | never, Result>(query: Query<Variables, Result>, variableValues?: Variables extends never ? never : Variables): Result;
|
|
3
48
|
//# sourceMappingURL=use-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"use-query.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,MAAM,EAClF,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,EAC/B,cAAc,CAAC,EAAE,SAAS,SAAS,KAAK,GAAG,KAAK,GAAG,SAAS,GAC7D,MAAM,CAAA"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { ObjectSlug } from "../object-slug.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get information about the current record.
|
|
4
|
+
*/
|
|
2
5
|
export declare function useRecord(): {
|
|
6
|
+
/**
|
|
7
|
+
* The ID of the current record.
|
|
8
|
+
*/
|
|
3
9
|
recordId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The object type of the current record.
|
|
12
|
+
*/
|
|
4
13
|
object: ObjectSlug;
|
|
5
14
|
};
|
|
6
15
|
//# sourceMappingURL=use-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-record.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-record.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;CACrB,CAAA"}
|