@gooddata/sdk-ui-catalog 11.50.0-alpha.2 → 11.50.0-alpha.4

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.
Files changed (105) hide show
  1. package/esm/AnalyticsCatalogDetail.d.ts.map +1 -1
  2. package/esm/AnalyticsCatalogDetail.js +1 -3
  3. package/esm/asCode/AsCodeCreateDialog.d.ts +3 -7
  4. package/esm/asCode/AsCodeCreateDialog.d.ts.map +1 -1
  5. package/esm/asCode/AsCodeCreateDialog.js +13 -23
  6. package/esm/asCode/AsCodeDeleteDialog.d.ts +1 -6
  7. package/esm/asCode/AsCodeDeleteDialog.d.ts.map +1 -1
  8. package/esm/asCode/AsCodeDeleteDialog.js +11 -20
  9. package/esm/asCode/AsCodeDetailActions.d.ts +2 -11
  10. package/esm/asCode/AsCodeDetailActions.d.ts.map +1 -1
  11. package/esm/asCode/AsCodeDetailActions.js +16 -22
  12. package/esm/asCode/AsCodeDialog.d.ts +12 -17
  13. package/esm/asCode/AsCodeDialog.d.ts.map +1 -1
  14. package/esm/asCode/AsCodeDialog.js +59 -27
  15. package/esm/asCode/AsCodeEditDialog.d.ts +3 -8
  16. package/esm/asCode/AsCodeEditDialog.d.ts.map +1 -1
  17. package/esm/asCode/AsCodeEditDialog.js +4 -21
  18. package/esm/asCode/descriptor.d.ts +78 -104
  19. package/esm/asCode/descriptor.d.ts.map +1 -1
  20. package/esm/asCode/descriptor.js +13 -4
  21. package/esm/asCode/serverIdentity.d.ts +7 -0
  22. package/esm/asCode/serverIdentity.d.ts.map +1 -0
  23. package/esm/asCode/serverIdentity.js +2 -0
  24. package/esm/asCode/tests/withMutationPort.d.ts +4 -0
  25. package/esm/asCode/tests/withMutationPort.d.ts.map +1 -0
  26. package/esm/asCode/tests/withMutationPort.js +5 -0
  27. package/esm/asCode/useAsCodeBase.d.ts +5 -8
  28. package/esm/asCode/useAsCodeBase.d.ts.map +1 -1
  29. package/esm/asCode/useAsCodeBase.js +20 -18
  30. package/esm/asCode/useAsCodeLoadFailure.d.ts +8 -0
  31. package/esm/asCode/useAsCodeLoadFailure.d.ts.map +1 -0
  32. package/esm/asCode/useAsCodeLoadFailure.js +21 -0
  33. package/esm/asCode/useMutationPort.d.ts +4 -0
  34. package/esm/asCode/useMutationPort.d.ts.map +1 -0
  35. package/esm/asCode/useMutationPort.js +9 -0
  36. package/esm/asCode/validateYaml.d.ts +16 -12
  37. package/esm/asCode/validateYaml.d.ts.map +1 -1
  38. package/esm/asCode/validateYaml.js +8 -9
  39. package/esm/asCodeRegistry.d.ts +5 -14
  40. package/esm/asCodeRegistry.d.ts.map +1 -1
  41. package/esm/asCodeRegistry.js +29 -15
  42. package/esm/catalog/Catalog.d.ts.map +1 -1
  43. package/esm/catalog/Catalog.js +2 -8
  44. package/esm/catalogDetail/CatalogDetailActionBar.d.ts.map +1 -1
  45. package/esm/catalogDetail/CatalogDetailActionBar.js +4 -8
  46. package/esm/catalogDetail/CatalogDetailActions.d.ts.map +1 -1
  47. package/esm/catalogDetail/CatalogDetailActions.js +2 -6
  48. package/esm/catalogDetail/openHandlerEvent.d.ts +6 -0
  49. package/esm/catalogDetail/openHandlerEvent.d.ts.map +1 -0
  50. package/esm/catalogDetail/openHandlerEvent.js +10 -0
  51. package/esm/header/CreateObjectButton.d.ts +1 -3
  52. package/esm/header/CreateObjectButton.d.ts.map +1 -1
  53. package/esm/header/CreateObjectButton.js +10 -22
  54. package/esm/index.d.ts +2 -0
  55. package/esm/index.d.ts.map +1 -1
  56. package/esm/index.js +5 -0
  57. package/esm/insight/gate.d.ts +4 -0
  58. package/esm/insight/gate.d.ts.map +1 -0
  59. package/esm/insight/gate.js +4 -0
  60. package/esm/insight/insightCodecContext.d.ts +22 -0
  61. package/esm/insight/insightCodecContext.d.ts.map +1 -0
  62. package/esm/insight/insightCodecContext.js +30 -0
  63. package/esm/insight/insightCopy.d.ts +4 -0
  64. package/esm/insight/insightCopy.d.ts.map +1 -0
  65. package/esm/insight/insightCopy.js +25 -0
  66. package/esm/insight/insightDescriptor.d.ts +7 -0
  67. package/esm/insight/insightDescriptor.d.ts.map +1 -0
  68. package/esm/insight/insightDescriptor.js +69 -0
  69. package/esm/insight/insightMutationPort.d.ts +13 -0
  70. package/esm/insight/insightMutationPort.d.ts.map +1 -0
  71. package/esm/insight/insightMutationPort.js +59 -0
  72. package/esm/localization/bundles/en-US.localization-bundle.d.ts +72 -0
  73. package/esm/localization/bundles/en-US.localization-bundle.d.ts.map +1 -1
  74. package/esm/localization/bundles/en-US.localization-bundle.js +72 -0
  75. package/esm/metric/gate.d.ts +1 -6
  76. package/esm/metric/gate.d.ts.map +1 -1
  77. package/esm/metric/gate.js +1 -9
  78. package/esm/metric/metricConverter.d.ts +8 -17
  79. package/esm/metric/metricConverter.d.ts.map +1 -1
  80. package/esm/metric/metricConverter.js +10 -24
  81. package/esm/metric/metricDescriptor.d.ts.map +1 -1
  82. package/esm/metric/metricDescriptor.js +19 -8
  83. package/esm/metric/metricMutationPort.d.ts +5 -3
  84. package/esm/metric/metricMutationPort.d.ts.map +1 -1
  85. package/esm/metric/metricMutationPort.js +21 -14
  86. package/esm/metric/metricValidation.d.ts.map +1 -1
  87. package/esm/metric/metricValidation.js +7 -4
  88. package/esm/metric/tests/metricMutationPort.test.utils.d.ts +1 -4
  89. package/esm/metric/tests/metricMutationPort.test.utils.d.ts.map +1 -1
  90. package/esm/metric/tests/metricMutationPort.test.utils.js +1 -19
  91. package/esm/parameter/gate.d.ts +1 -5
  92. package/esm/parameter/gate.d.ts.map +1 -1
  93. package/esm/parameter/gate.js +1 -8
  94. package/esm/parameter/parameterDescriptor.d.ts.map +1 -1
  95. package/esm/parameter/parameterDescriptor.js +22 -13
  96. package/esm/parameter/parameterValidation.d.ts.map +1 -1
  97. package/esm/parameter/parameterValidation.js +11 -23
  98. package/esm/sdk-ui-catalog.d.ts +49 -0
  99. package/package.json +15 -15
  100. package/esm/asCode/AsCodeMutationContext.d.ts +0 -24
  101. package/esm/asCode/AsCodeMutationContext.d.ts.map +0 -1
  102. package/esm/asCode/AsCodeMutationContext.js +0 -40
  103. package/esm/asCode/gate.d.ts +0 -7
  104. package/esm/asCode/gate.d.ts.map +0 -1
  105. package/esm/asCode/gate.js +0 -11
@@ -5,64 +5,26 @@ import type { ICatalogItem, ICatalogItemRef } from "../catalogItem/types.js";
5
5
  import type { ObjectTypes } from "../objectType/constants.js";
6
6
  import type { ObjectType } from "../objectType/types.js";
7
7
  import type { useFeatureFlag } from "../permission/PermissionsContext.js";
8
- /** A feature-flag name, as accepted by {@link useFeatureFlag}. */
9
8
  export type AsCodeFeatureFlag = Parameters<typeof useFeatureFlag>[0];
10
- /**
11
- * The catalog object types editable as code. Add a member and the registry won't compile until it
12
- * registers a descriptor for the new type, whose own type then forces every field.
13
- */
14
- export type AsCodeObjectType = typeof ObjectTypes.METRIC | typeof ObjectTypes.PARAMETER;
15
- /**
16
- * The one field the generic layer reads off any as-code definition: an optional identity. Everything
17
- * else about a definition stays opaque to that layer.
18
- */
19
- export interface IAsCodeDefinition {
20
- id?: string;
21
- }
22
- /**
23
- * The entity-specific strings a generic as-code dialog needs. The generic chrome (Create/Save/Cancel/
24
- * Duplicate, the "Error:" label) is shared and lives in the dialog, not here — these are only the
25
- * strings that name or describe the entity.
26
- */
9
+ export type AsCodeObjectType = typeof ObjectTypes.METRIC | typeof ObjectTypes.PARAMETER | typeof ObjectTypes.VISUALIZATION;
27
10
  export interface IAsCodeMessages {
28
11
  createTitle: MessageDescriptor;
29
12
  editTitle: MessageDescriptor;
30
- /** Label of the duplicate action (edit-dialog button + detail menu); per-entity — a metric says
31
- * "Duplicate", a parameter "Save as new". */
32
13
  duplicate: MessageDescriptor;
33
- /** Default title seeded into a blank create. */
34
14
  createDefaultTitle: MessageDescriptor;
35
15
  createSuccess: MessageDescriptor;
36
16
  updateSuccess: MessageDescriptor;
37
- /** Heading above the editor, e.g. "Metric definition". */
38
17
  sectionHeader: MessageDescriptor;
39
- /** Tooltip explaining what the YAML should contain. */
40
18
  sectionHeaderTooltip: MessageDescriptor;
41
- /** Text of the docs link, e.g. "How to write a metric". */
42
19
  help: MessageDescriptor;
43
- /** Fallback shown when a save fails without a backend detail. */
44
20
  submitError: MessageDescriptor;
45
- /**
46
- * Shown when fetching the object to edit fails. A type that defines `port.load` should provide it;
47
- * without it a load failure closes the dialog silently. A type that never loads omits it.
48
- */
49
- loadError?: MessageDescriptor;
50
21
  deleteTitle: MessageDescriptor;
51
- /** Confirmation body; receives the object's `name` and a `b` bold-chunk renderer. */
52
22
  deleteBody: MessageDescriptor;
53
23
  deleteSubmit: MessageDescriptor;
54
24
  deleteSuccess: MessageDescriptor;
55
25
  deleteError: MessageDescriptor;
56
- /**
57
- * Warns that other objects depend on this one; receives their `count`. Only types that report a
58
- * referencing count (see `port.getReferencingObjectsCount`) provide it.
59
- */
60
- deleteUsageWarning?: MessageDescriptor;
61
26
  }
62
- /**
63
- * Outcome of validating YAML: the parsed definition, or an already-localized error message. The entity
64
- * localizes the error itself, so there is no shared error-code vocabulary.
65
- */
27
+ /** @internal */
66
28
  export type AsCodeValidation<TDef> = {
67
29
  isValid: true;
68
30
  definition: TDef;
@@ -71,90 +33,102 @@ export type AsCodeValidation<TDef> = {
71
33
  error: string;
72
34
  };
73
35
  /**
74
- * The per-entity editing behavior. Everything here can depend on the entity's own runtime context
75
- * (e.g. a parameter's enabled types), which is why it is delivered through a hook rather than as static
76
- * fields: the entity gathers its context, the generic shell never has to know about it.
36
+ * Identity rule per flow: `edit` keeps `fixedIdentifier`; `duplicate` accepts and ignores any id (the
37
+ * copy re-derives identity downstream); `create` applies the entity's own id policy.
38
+ * @internal
77
39
  */
78
- export interface IAsCodeEditing<TDef extends IAsCodeDefinition> {
79
- /** Autocompletion source fed to the shared `<YamlEditor>`. */
40
+ export type AsCodeValidationContext = {
41
+ intent: "create";
42
+ } | {
43
+ intent: "edit";
44
+ fixedIdentifier: string;
45
+ } | {
46
+ intent: "duplicate";
47
+ };
48
+ /** @internal */
49
+ export declare function fixedIdentifierOf(context: AsCodeValidationContext): string | undefined;
50
+ /** @internal */
51
+ export interface IAsCodeEditing<TDef> {
80
52
  completionSource: CompletionSource;
81
- /** Localized message the editor's inline linter shows on a YAML syntax error. */
82
53
  syntaxErrorMessage: string;
83
- /** Renders a definition to the YAML seed shown in the editor. */
84
54
  serialize(definition: TDef): string;
85
- /**
86
- * Parses + validates YAML, returning the definition or a localized error. Identity is fixed while
87
- * editing via `fixedIdentifier`.
88
- */
89
- validate(value: string, options: {
90
- fixedIdentifier?: string;
91
- }): AsCodeValidation<TDef>;
55
+ validate(value: string, context: AsCodeValidationContext): AsCodeValidation<TDef>;
56
+ /** Re-adds content the YAML can't express; applied on every persisting path. Omit if lossless. */
57
+ reconcile?(base: TDef, edited: TDef): TDef;
92
58
  }
93
59
  /**
94
- * Backend operations for one catalog as-code object type. Everything flows in the definition shape:
95
- * `load` returns the full editable definition (a metric's loaded measure already is one), and `update`
96
- * takes that as its `base`.
97
- *
98
- * `load` and `getReferencingObjectsCount` are optional capabilities. A type whose catalog item already
99
- * holds everything the editor needs omits `load` and supplies `editSeed` on the descriptor instead; a
100
- * type that tracks no referencing objects omits `getReferencingObjectsCount` (delete shows no warning).
60
+ * `update`'s `definition` (already reconciled) is authoritative for content; `base` supplies only the
61
+ * server-managed identity the definition shape cannot carry.
101
62
  */
102
- export interface IAsCodeMutationPort<TDef extends IAsCodeDefinition = IAsCodeDefinition, TItem extends ICatalogItem = ICatalogItem> {
63
+ export interface IAsCodeMutationPort<TDef = unknown, TItem extends ICatalogItem = ICatalogItem> {
103
64
  create(definition: TDef): Promise<TItem>;
104
65
  update(base: TDef, definition: TDef): Promise<TItem>;
105
66
  delete(ref: ICatalogItemRef): Promise<void>;
106
- load?(item: TItem): Promise<TDef>;
107
- /** How many objects reference this one — used to warn before deletion. */
108
- getReferencingObjectsCount?(item: TItem): Promise<number>;
109
67
  }
110
68
  /**
111
- * The contract one entity type implements so the shared as-code shell (dialogs, mutation ports, detail
112
- * actions) can drive it. Adding a type is "write one descriptor and register it"; the shell never
113
- * imports the concrete type.
114
- *
115
- * `useEditing` is a hook and differs in shape across types, so a component that calls it must bind to
116
- * ONE descriptor per mount and remount when the type changes (the detail dispatch keys on `objectType`
117
- * for this) — otherwise the hook order would shift and break the rules of hooks.
69
+ * The `never` fields keep the variants exclusive: excess-property checking runs per union constituent,
70
+ * so without them a literal mixing both (e.g. `load` with no `loadError`) would typecheck.
71
+ * @internal
72
+ */
73
+ export type AsCodeSeed<TDef, TItem extends ICatalogItem> = {
74
+ editSeed(item: TItem): TDef;
75
+ load?: never;
76
+ loadError?: never;
77
+ } | {
78
+ editSeed?: never;
79
+ load(backend: IAnalyticalBackend, workspace: string, item: TItem): Promise<TDef>;
80
+ loadError: MessageDescriptor;
81
+ };
82
+ /** @internal */
83
+ export declare function isLoadSeed<TDef, TItem extends ICatalogItem>(seed: AsCodeSeed<TDef, TItem>): seed is Extract<AsCodeSeed<TDef, TItem>, {
84
+ loadError: MessageDescriptor;
85
+ }>;
86
+ /** @internal */
87
+ export declare function loadErrorOf(descriptor: IAsCodeDescriptor): MessageDescriptor | undefined;
88
+ /** @internal */
89
+ export type AsCodeReferenceCount<TItem extends ICatalogItem> = {
90
+ count(backend: IAnalyticalBackend, workspace: string, item: TItem): Promise<number>;
91
+ usageWarning: MessageDescriptor;
92
+ };
93
+ /**
94
+ * Duplicate-collision retry: the create dialog retries without the id when a copy's derived id
95
+ * collides. Omitted by a type whose creates never carry an id.
96
+ * @internal
97
+ */
98
+ export type AsCodeIdentity<TDef> = {
99
+ read(definition: TDef): string | undefined;
100
+ strip(definition: TDef): TDef;
101
+ };
102
+ /**
103
+ * A component calling `useEditing` (or the other hooks here) must bind to ONE descriptor per mount and
104
+ * remount when the type changes (the detail dispatch keys on `objectType`), or the hook order shifts
105
+ * and breaks the rules of hooks.
118
106
  */
119
- export interface IAsCodeDescriptor<TDef extends IAsCodeDefinition = IAsCodeDefinition, TItem extends ICatalogItem = ICatalogItem> {
107
+ export interface IAsCodeDescriptor<TDef = unknown, TItem extends ICatalogItem = ICatalogItem> {
120
108
  objectType: ObjectType;
121
109
  docsUrl: string;
122
- /**
123
- * Gates whether this type's in-catalog editor is offered, paired with the per-item edit
124
- * permission. Omit it for a type that is always editable (no feature-flag gate).
125
- */
126
110
  featureFlag?: AsCodeFeatureFlag;
127
111
  messages: IAsCodeMessages;
128
- /** The entity's per-mount editing behavior; a hook so it can read its own context. */
129
- useEditing(): IAsCodeEditing<TDef>;
130
- /** Builds this type's backend adapter; the mutation provider calls it once per backend/workspace. */
131
- createMutationPort(backend: IAnalyticalBackend, workspace: string): IAsCodeMutationPort<TDef, TItem>;
132
- /** A blank definition for a fresh create, seeded with a default title. */
133
- emptyDefinition(defaultTitle: string): TDef;
112
+ /** `null` while an async editing brain is still loading. */
113
+ useEditing(): IAsCodeEditing<TDef> | null;
134
114
  /**
135
- * Maps a catalog item to its editable definition without a fetch. Provided by types whose item
136
- * already holds everything the editor needs; a type that must fetch (see `port.load`) omits it.
137
- * A descriptor provides exactly one of `editSeed` / `port.load`.
115
+ * Starts/retries building the async editing brain; the promise rejects when it can't be built. The
116
+ * returned function must keep a stable identity while the request target is unchanged it is an
117
+ * effect dependency, so a new identity re-issues the request.
138
118
  */
139
- editSeed?(item: TItem): TDef;
140
- /** Derives a duplicate's definition from a source definition (bumps title, re-derives identity). */
119
+ useRequestEditing?(): () => Promise<void>;
120
+ useIsItemEditable?(item: TItem): boolean;
121
+ /** Extra requirement for creation, ANDed with the feature flag and manage permission. */
122
+ useCreateGate?(): boolean;
123
+ createMutationPort(backend: IAnalyticalBackend, workspace: string): IAsCodeMutationPort<TDef, TItem>;
124
+ emptyDefinition(defaultTitle: string): TDef;
125
+ seed: AsCodeSeed<TDef, TItem>;
126
+ referenceCounted?: AsCodeReferenceCount<TItem>;
127
+ identity?: AsCodeIdentity<TDef>;
141
128
  toCopy(source: TDef): TDef;
142
- /**
143
- * Overlays the author's parsed YAML edits onto the full definition, re-adding fields the YAML
144
- * cannot express (metric: metricType/isHiddenFromKda). Used both to seed a duplicate from the open
145
- * editor and to reconcile a duplicate on save. Omitted — meaning `(_, parsed) => parsed` — for
146
- * types whose YAML round-trips 1:1 to the definition (parameter).
147
- */
148
- applyYamlEdits?(full: TDef, parsed: TDef): TDef;
149
- /**
150
- * Label of the action that opens the object in its standalone editor; declaring it signals the type
151
- * has such an editor. Omit it for a type with none (a parameter).
152
- */
129
+ /** Presence signals the type has a standalone editor; its label opens it. */
153
130
  openAction?: MessageDescriptor;
154
131
  }
155
- /**
156
- * Identity helper that keeps a descriptor's generics inferred at authoring while letting the registry
157
- * store it widened, so the generic components never have to narrow.
158
- */
159
- export declare function defineAsCodeDescriptor<TDef extends IAsCodeDefinition, TItem extends ICatalogItem>(descriptor: IAsCodeDescriptor<TDef, TItem>): IAsCodeDescriptor<TDef, TItem>;
132
+ /** Infers a descriptor's generics at authoring while the registry stores it widened. */
133
+ export declare function defineAsCodeDescriptor<TDef, TItem extends ICatalogItem>(descriptor: IAsCodeDescriptor<TDef, TItem>): IAsCodeDescriptor<TDef, TItem>;
160
134
  //# sourceMappingURL=descriptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../src/asCode/descriptor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CA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IAC1B,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAErG,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,gBAAgB,CAAC,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,6EAA6E;IAC7E,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAED,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,KAAK,SAAS,YAAY,EACnE,UAAU,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,GAC3C,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAEhC"}
@@ -1,8 +1,17 @@
1
1
  // (C) 2026 GoodData Corporation
2
- /**
3
- * Identity helper that keeps a descriptor's generics inferred at authoring while letting the registry
4
- * store it widened, so the generic components never have to narrow.
5
- */
2
+ /** @internal */
3
+ export function fixedIdentifierOf(context) {
4
+ return context.intent === "edit" ? context.fixedIdentifier : undefined;
5
+ }
6
+ /** @internal */
7
+ export function isLoadSeed(seed) {
8
+ return seed.load !== undefined;
9
+ }
10
+ /** @internal */
11
+ export function loadErrorOf(descriptor) {
12
+ return isLoadSeed(descriptor.seed) ? descriptor.seed.loadError : undefined;
13
+ }
14
+ /** Infers a descriptor's generics at authoring while the registry stores it widened. */
6
15
  export function defineAsCodeDescriptor(descriptor) {
7
16
  return descriptor;
8
17
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A saved object's server-managed fields (those beyond its definition). The Pick keeps required
3
+ * saved-only fields required, so a new one fails the build at the pick rather than being dropped.
4
+ * @internal
5
+ */
6
+ export type ServerIdentity<TSaved, TDef> = Pick<TSaved, Exclude<keyof TSaved, keyof TDef>>;
7
+ //# sourceMappingURL=serverIdentity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverIdentity.d.ts","sourceRoot":"","sources":["../../src/asCode/serverIdentity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ // (C) 2026 GoodData Corporation
2
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { IAsCodeDescriptor, IAsCodeMutationPort } from "../descriptor.js";
2
+ /** A descriptor whose `createMutationPort` yields `port` — the test seam for the mutation adapter. */
3
+ export declare function withMutationPort(descriptor: IAsCodeDescriptor, port: IAsCodeMutationPort): IAsCodeDescriptor;
4
+ //# sourceMappingURL=withMutationPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withMutationPort.d.ts","sourceRoot":"","sources":["../../../src/asCode/tests/withMutationPort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,wGAAsG;AACtG,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,iBAAiB,EAC7B,IAAI,EAAE,mBAAmB,GAC1B,iBAAiB,CAEnB"}
@@ -0,0 +1,5 @@
1
+ // (C) 2026 GoodData Corporation
2
+ /** A descriptor whose `createMutationPort` yields `port` — the test seam for the mutation adapter. */
3
+ export function withMutationPort(descriptor, port) {
4
+ return { ...descriptor, createMutationPort: () => port };
5
+ }
@@ -1,18 +1,15 @@
1
1
  import type { ICatalogItem } from "../catalogItem/types.js";
2
- import type { IAsCodeDefinition, IAsCodeDescriptor, IAsCodeMutationPort } from "./descriptor.js";
2
+ import { type IAsCodeDescriptor, type IAsCodeMutationPort } from "./descriptor.js";
3
3
  type AsCodeBase = {
4
- /** The editable definition for the item, or `undefined` while loading / when no item was given. */
5
- base: IAsCodeDefinition | undefined;
4
+ base: unknown;
6
5
  isLoading: boolean;
7
6
  port: IAsCodeMutationPort;
8
7
  };
9
8
  /**
10
- * Resolves an existing item's editable definition for the edit dialog and for the create dialog when
11
- * duplicating. A fetching type (metric, `port.load`) resolves asynchronously; a mapping type
12
- * (parameter, `editSeed`) resolves synchronously, so it never flashes a loading state. `onError` fires
13
- * on a failed fetch; an `undefined` item (a blank create) resolves to nothing.
9
+ * Resolves an item's editable definition — async for a `seed.load` type, sync for `seed.editSeed`. A
10
+ * failed fetch toasts the seed's `loadError` and calls `onClose`.
14
11
  * @internal
15
12
  */
16
- export declare function useAsCodeBase(descriptor: IAsCodeDescriptor, item: ICatalogItem | undefined, onError: () => void): AsCodeBase;
13
+ export declare function useAsCodeBase(descriptor: IAsCodeDescriptor, item: ICatalogItem | undefined, onClose: () => void): AsCodeBase;
17
14
  export {};
18
15
  //# sourceMappingURL=useAsCodeBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAsCodeBase.d.ts","sourceRoot":"","sources":["../../src/asCode/useAsCodeBase.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEjG,KAAK,UAAU,GAAG;IACd,mGAAmG;IACnG,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CACzB,UAAU,EAAE,iBAAiB,EAC7B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,IAAI,GACpB,UAAU,CAsBZ"}
1
+ {"version":3,"file":"useAsCodeBase.d.ts","sourceRoot":"","sources":["../../src/asCode/useAsCodeBase.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAC;AAI/F,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CACzB,UAAU,EAAE,iBAAiB,EAC7B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,IAAI,GACpB,UAAU,CAsBZ"}
@@ -1,27 +1,29 @@
1
1
  // (C) 2026 GoodData Corporation
2
- import { useCancelablePromise } from "@gooddata/sdk-ui";
3
- import { useAsCodePort } from "./AsCodeMutationContext.js";
2
+ import { useBackendStrict, useCancelablePromise, useWorkspaceStrict } from "@gooddata/sdk-ui";
3
+ import { isLoadSeed } from "./descriptor.js";
4
+ import { useAsCodeLoadFailure } from "./useAsCodeLoadFailure.js";
5
+ import { useMutationPort } from "./useMutationPort.js";
4
6
  /**
5
- * Resolves an existing item's editable definition for the edit dialog and for the create dialog when
6
- * duplicating. A fetching type (metric, `port.load`) resolves asynchronously; a mapping type
7
- * (parameter, `editSeed`) resolves synchronously, so it never flashes a loading state. `onError` fires
8
- * on a failed fetch; an `undefined` item (a blank create) resolves to nothing.
7
+ * Resolves an item's editable definition — async for a `seed.load` type, sync for `seed.editSeed`. A
8
+ * failed fetch toasts the seed's `loadError` and calls `onClose`.
9
9
  * @internal
10
10
  */
11
- export function useAsCodeBase(descriptor, item, onError) {
12
- const port = useAsCodePort(descriptor.objectType);
13
- const load = port.load;
14
- const { result: loaded } = useCancelablePromise({ promise: item && load ? () => load(item) : undefined, onError }, [item, port]);
11
+ export function useAsCodeBase(descriptor, item, onClose) {
12
+ const backend = useBackendStrict();
13
+ const workspace = useWorkspaceStrict();
14
+ const fail = useAsCodeLoadFailure(descriptor, onClose);
15
+ const port = useMutationPort(descriptor);
16
+ const seed = descriptor.seed;
17
+ const load = isLoadSeed(seed) ? seed.load : undefined;
18
+ const { result: loaded } = useCancelablePromise({
19
+ promise: item && load ? () => load(backend, workspace, item) : undefined,
20
+ onError: fail,
21
+ }, [item, backend, workspace]);
15
22
  if (item === undefined) {
16
23
  return { base: undefined, isLoading: false, port };
17
24
  }
18
- if (load) {
19
- return { base: loaded, isLoading: loaded === undefined, port };
25
+ if (!isLoadSeed(seed)) {
26
+ return { base: seed.editSeed(item), isLoading: false, port };
20
27
  }
21
- if (!descriptor.editSeed) {
22
- // A descriptor must provide exactly one of `port.load` / `editSeed`; without either there is
23
- // no way to seed the editor. Fail loudly rather than open a silently-blank editor.
24
- throw new Error(`As-code descriptor "${descriptor.objectType}" provides neither port.load nor editSeed.`);
25
- }
26
- return { base: descriptor.editSeed(item), isLoading: false, port };
28
+ return { base: loaded, isLoading: loaded === undefined, port };
27
29
  }
@@ -0,0 +1,8 @@
1
+ import { type IAsCodeDescriptor } from "./descriptor.js";
2
+ /**
3
+ * Identity-stable across the unstable toast and close identities, so an effect depending on it does
4
+ * not re-fire.
5
+ * @internal
6
+ */
7
+ export declare function useAsCodeLoadFailure(descriptor: IAsCodeDescriptor, onClose: () => void): () => void;
8
+ //# sourceMappingURL=useAsCodeLoadFailure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsCodeLoadFailure.d.ts","sourceRoot":"","sources":["../../src/asCode/useAsCodeLoadFailure.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,iBAAiB,EAAe,MAAM,iBAAiB,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAUnG"}
@@ -0,0 +1,21 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { useCallback } from "react";
3
+ import { useAutoupdateRef } from "@gooddata/sdk-ui";
4
+ import { useToastMessage } from "@gooddata/sdk-ui-kit";
5
+ import { loadErrorOf } from "./descriptor.js";
6
+ /**
7
+ * Identity-stable across the unstable toast and close identities, so an effect depending on it does
8
+ * not re-fire.
9
+ * @internal
10
+ */
11
+ export function useAsCodeLoadFailure(descriptor, onClose) {
12
+ const { addError } = useToastMessage();
13
+ const latest = useAutoupdateRef({ addError, onClose, loadError: loadErrorOf(descriptor) });
14
+ return useCallback(() => {
15
+ const { addError, onClose, loadError } = latest.current;
16
+ if (loadError) {
17
+ addError(loadError);
18
+ }
19
+ onClose();
20
+ }, [latest]);
21
+ }
@@ -0,0 +1,4 @@
1
+ import type { IAsCodeDescriptor, IAsCodeMutationPort } from "./descriptor.js";
2
+ /** @internal */
3
+ export declare function useMutationPort(descriptor: IAsCodeDescriptor): IAsCodeMutationPort;
4
+ //# sourceMappingURL=useMutationPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMutationPort.d.ts","sourceRoot":"","sources":["../../src/asCode/useMutationPort.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,UAAU,EAAE,iBAAiB,GAAG,mBAAmB,CAIlF"}
@@ -0,0 +1,9 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { useMemo } from "react";
3
+ import { useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
4
+ /** @internal */
5
+ export function useMutationPort(descriptor) {
6
+ const backend = useBackendStrict();
7
+ const workspace = useWorkspaceStrict();
8
+ return useMemo(() => descriptor.createMutationPort(backend, workspace), [backend, descriptor, workspace]);
9
+ }
@@ -1,14 +1,21 @@
1
1
  import type * as z from "zod/mini";
2
2
  /**
3
- * Neutral result of the shared YAML validation skeleton, before a type shapes it into its own
4
- * result. `data` is the parsed-and-schema-validated value; the caller converts it to a definition.
3
+ * Neutral result of the shared YAML validation skeleton, before a type shapes it into its own result.
4
+ * `data` is the parsed-and-schema-validated value; the caller converts it to a definition. A `schema`
5
+ * failure hands the caller the `error` and the `parsed` value to classify against its own error codes;
6
+ * the other kinds are already the codes every as-code type shares.
5
7
  */
6
- export type YamlValidation<TData, TErrorCode extends string> = {
8
+ export type YamlValidation<TData> = {
7
9
  ok: true;
8
10
  data: TData;
9
11
  } | {
10
12
  ok: false;
11
- errorCode: TErrorCode | "empty" | "syntax" | "idImmutable";
13
+ kind: "empty" | "syntax" | "idImmutable";
14
+ } | {
15
+ ok: false;
16
+ kind: "schema";
17
+ error: z.core.$ZodError;
18
+ parsed: unknown;
12
19
  };
13
20
  type SafeParseSchema<TData> = {
14
21
  safeParse(value: unknown): {
@@ -19,21 +26,18 @@ type SafeParseSchema<TData> = {
19
26
  error: z.core.$ZodError;
20
27
  };
21
28
  };
22
- type ValidateYamlOptions<TData, TErrorCode extends string> = {
29
+ type ValidateYamlOptions<TData> = {
23
30
  schema: SafeParseSchema<TData>;
24
- /** Maps a schema failure to a type-specific error code. */
25
- classifyError: (error: z.core.$ZodError, parsed: unknown) => TErrorCode;
26
31
  /** When set, the parsed `id` must match it, else `idImmutable` (identity is fixed while editing). */
27
32
  fixedIdentifier?: string;
28
33
  };
29
34
  /**
30
- * Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, validate
31
- * against the schema, and enforce identity immutability. Type-specific concerns the schema, how a
32
- * schema failure maps to an error code, and how the validated data becomes a definition are the
33
- * caller's.
35
+ * Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, validate against
36
+ * the schema, and enforce identity immutability. The schema itself and the conversion of validated data
37
+ * into a definition are the caller's.
34
38
  */
35
39
  export declare function validateYaml<TData extends {
36
40
  id?: string;
37
- }, TErrorCode extends string>(value: string, { schema, classifyError, fixedIdentifier }: ValidateYamlOptions<TData, TErrorCode>): YamlValidation<TData, TErrorCode>;
41
+ }>(value: string, { schema, fixedIdentifier }: ValidateYamlOptions<TData>): YamlValidation<TData>;
38
42
  export {};
39
43
  //# sourceMappingURL=validateYaml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateYaml.d.ts","sourceRoot":"","sources":["../../src/asCode/validateYaml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,EAAE,UAAU,SAAS,MAAM,IACrD;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACzB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAA;CAAE,CAAC;AAEhF,KAAK,eAAe,CAAC,KAAK,IAAI;IAC1B,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAA;KAAE,CAAC;CAC3G,CAAC;AAEF,KAAK,mBAAmB,CAAC,KAAK,EAAE,UAAU,SAAS,MAAM,IAAI;IACzD,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAC/B,2DAA2D;IAC3D,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,KAAK,UAAU,CAAC;IACxE,qGAAqG;IACrG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,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AAM,EACb,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,mBAAmB,CAAC,KAAK,CAAC,GACxD,cAAc,CAAC,KAAK,CAAC,CAsBvB"}
@@ -1,28 +1,27 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { parse as parseYaml } from "yaml";
3
3
  /**
4
- * Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, validate
5
- * against the schema, and enforce identity immutability. Type-specific concerns the schema, how a
6
- * schema failure maps to an error code, and how the validated data becomes a definition are the
7
- * caller's.
4
+ * Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, validate against
5
+ * the schema, and enforce identity immutability. The schema itself and the conversion of validated data
6
+ * into a definition are the caller's.
8
7
  */
9
- export function validateYaml(value, { schema, classifyError, fixedIdentifier }) {
8
+ export function validateYaml(value, { schema, fixedIdentifier }) {
10
9
  if (value.trim() === "") {
11
- return { ok: false, errorCode: "empty" };
10
+ return { ok: false, kind: "empty" };
12
11
  }
13
12
  let parsed;
14
13
  try {
15
14
  parsed = parseYaml(value, { strict: true });
16
15
  }
17
16
  catch {
18
- return { ok: false, errorCode: "syntax" };
17
+ return { ok: false, kind: "syntax" };
19
18
  }
20
19
  const result = schema.safeParse(parsed);
21
20
  if (!result.success) {
22
- return { ok: false, errorCode: classifyError(result.error, parsed) };
21
+ return { ok: false, kind: "schema", error: result.error, parsed };
23
22
  }
24
23
  if (fixedIdentifier !== undefined && result.data.id !== fixedIdentifier) {
25
- return { ok: false, errorCode: "idImmutable" };
24
+ return { ok: false, kind: "idImmutable" };
26
25
  }
27
26
  return { ok: true, data: result.data };
28
27
  }
@@ -1,20 +1,11 @@
1
1
  import type { AsCodeObjectType, IAsCodeDescriptor } from "./asCode/descriptor.js";
2
2
  import type { ObjectType } from "./objectType/types.js";
3
- /**
4
- * Every as-code descriptor, keyed by type — the one place the concrete descriptors are registered. The
5
- * key is the full `AsCodeObjectType` union, so a missing type is a compile error.
6
- * @internal
7
- */
3
+ /** @internal */
8
4
  export declare const asCodeDescriptors: Record<AsCodeObjectType, IAsCodeDescriptor>;
9
- /**
10
- * The as-code descriptor for a catalog object type, or `undefined` if the type is not editable as code.
11
- * @internal
12
- */
5
+ /** @internal */
13
6
  export declare function getAsCodeDescriptor(type: ObjectType): IAsCodeDescriptor | undefined;
14
- /**
15
- * Whether this descriptor's editor is enabled by the feature flags. A descriptor with no `featureFlag`
16
- * is always editable; `undefined` (not an as-code type) never is.
17
- * @internal
18
- */
7
+ /** A descriptor with no `featureFlag` is always editable; `undefined` (not an as-code type) never is. @internal */
19
8
  export declare function useIsAsCodeTypeEditable(descriptor: IAsCodeDescriptor | undefined): boolean;
9
+ /** @internal */
10
+ export declare function useCreatableObjectTypes(): ReadonlySet<AsCodeObjectType>;
20
11
  //# sourceMappingURL=asCodeRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asCodeRegistry.d.ts","sourceRoot":"","sources":["../src/asCodeRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAGzE,CAAC;AAMF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,GAAG,SAAS,CAEnF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAM1F"}
1
+ {"version":3,"file":"asCodeRegistry.d.ts","sourceRoot":"","sources":["../src/asCodeRegistry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAIzE,CAAC;AAMF,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,GAAG,SAAS,CAEnF;AAED,mHAAmH;AACnH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAM1F;AASD,gBAAgB;AAChB,wBAAgB,uBAAuB,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAcvE"}