@elementumai/edk 0.8.0-preview.11 → 0.8.1

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 (165) hide show
  1. package/README.md +378 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +65 -2
  6. package/dist-sdk/src/catalog/from-authoring.js +6 -1
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +83 -6
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +14 -0
  14. package/dist-sdk/src/catalog/types.d.ts +60 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +20 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +18 -0
  22. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  23. package/dist-sdk/src/engine/build/source-context.js +23 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  26. package/dist-sdk/src/engine/pull/org.js +34 -4
  27. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  28. package/dist-sdk/src/engine/tf/index.js +1 -1
  29. package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
  30. package/dist-sdk/src/engine/tf/labels.js +71 -0
  31. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  32. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  33. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  34. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
  37. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  38. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  39. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
  40. package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
  41. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  42. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  43. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
  46. package/dist-sdk/src/entities/agent/from-tf.js +135 -15
  47. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  48. package/dist-sdk/src/entities/agent/module.js +8 -2
  49. package/dist-sdk/src/entities/agent/to-tf.js +62 -10
  50. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  51. package/dist-sdk/src/entities/agent/tools.js +46 -7
  52. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
  56. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  57. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  58. package/dist-sdk/src/entities/app/build.d.ts +63 -13
  59. package/dist-sdk/src/entities/app/build.js +48 -1
  60. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  61. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/from-tf.js +32 -15
  63. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/app/index.js +2 -1
  65. package/dist-sdk/src/entities/app/module.js +9 -2
  66. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  67. package/dist-sdk/src/entities/app/to-tf.js +33 -4
  68. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  69. package/dist-sdk/src/entities/automation/build.js +48 -36
  70. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  71. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  72. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
  73. package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
  74. package/dist-sdk/src/entities/automation/filter.js +12 -2
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  76. package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
  77. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  78. package/dist-sdk/src/entities/automation/index.js +4 -0
  79. package/dist-sdk/src/entities/automation/module.js +29 -32
  80. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  81. package/dist-sdk/src/entities/automation/operators.js +27 -1
  82. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  84. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  85. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  86. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  87. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  88. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  89. package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
  90. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  91. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  92. package/dist-sdk/src/entities/automation/types.js +76 -46
  93. package/dist-sdk/src/entities/element/build.d.ts +23 -10
  94. package/dist-sdk/src/entities/element/build.js +1 -0
  95. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/element/from-tf.js +18 -3
  97. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  98. package/dist-sdk/src/entities/element/index.js +2 -1
  99. package/dist-sdk/src/entities/element/module.js +3 -1
  100. package/dist-sdk/src/entities/element/to-tf.js +21 -3
  101. package/dist-sdk/src/entities/field/build.d.ts +56 -13
  102. package/dist-sdk/src/entities/field/build.js +10 -0
  103. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  104. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  105. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  106. package/dist-sdk/src/entities/field/module.js +3 -2
  107. package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
  108. package/dist-sdk/src/entities/field/to-tf.js +62 -17
  109. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  110. package/dist-sdk/src/entities/field/types.js +34 -12
  111. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  112. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  113. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  114. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  115. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  116. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  117. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  118. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  119. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  120. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  121. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  122. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  123. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  124. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  125. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  126. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  127. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  128. package/dist-sdk/src/entities/org/connector.js +12 -14
  129. package/dist-sdk/src/entities/org/group.js +10 -1
  130. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  131. package/dist-sdk/src/entities/org/index.js +1 -0
  132. package/dist-sdk/src/entities/org/user.js +10 -1
  133. package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
  134. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  135. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  136. package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  138. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  140. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
  141. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  142. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  143. package/dist-sdk/src/entities/skill/module.js +6 -1
  144. package/dist-sdk/src/entities/skill/to-tf.js +3 -2
  145. package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
  146. package/dist-sdk/src/entities/skill/tools.js +17 -0
  147. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
  148. package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
  149. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  152. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  153. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  154. package/dist-sdk/src/entities/view/to-tf.js +33 -18
  155. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  156. package/dist-sdk/src/entities/view/types.js +1 -1
  157. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  158. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  159. package/dist-sdk/src/graph/index.d.ts +8 -0
  160. package/dist-sdk/src/graph/index.js +13 -9
  161. package/dist-sdk/src/graph/modules.js +6 -1
  162. package/dist-sdk/src/graph/types.d.ts +77 -3
  163. package/package.json +42 -14
  164. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  165. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
@@ -1,22 +1,20 @@
1
1
  /**
2
- * Document model authoring. Unlike every other entity in this SDK, create and
3
- * update go straight through the tenant graph (`elementum-entity-client/clients/document-models/`)
4
- * — antman has no REST endpoint for this entity at all.
5
- *
6
- * The platform models six variants (AI extraction, Excel, an Excel-cell
7
- * variant, invoice, JSON, OCR, XML) behind one `documentModelCreate`/
8
- * `documentModelUpdate` mutation pair, each populating exactly one input
9
- * slot. `DocumentModelOptions` mirrors that as a discriminated union on
10
- * `type`. Excel-cell has no update path on the graph for its own fields
11
- * (only `name` can change) — `wire-client.ts`'s update dispatch throws for
12
- * that variant if anything beyond `name` changed.
2
+ * File-reader authoring. Targets the real terraform resources
3
+ * (`elementum_excel_file_reader`, `elementum_json_file_reader`,
4
+ * `elementum_text_file_reader`) — replaces an earlier `defineFileReader` that
5
+ * targeted a pre-refactor, non-terraform GraphQL mutation path
6
+ * (`documentModelCreate`/`documentModelUpdate` against "the tenant graph")
7
+ * with a different, incompatible option shape. That path was never wired
8
+ * into `elementum build`/`pull` (confirmed: nothing outside this directory
9
+ * referenced it) — this is a from-scratch terraform-facing builder, not a
10
+ * migration of the old one.
13
11
  */
14
12
  import type { FileReaderCatalogRef } from "../../catalog/index.js";
15
13
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
16
- import type { FileReaderCreateInput, FileReaderUpdateInput, InvoiceFieldLabel } from "../../../elementum-entity-client/clients/document-models/models/document-model.js";
17
14
  /**
18
- * A field in a JSON/XML document model's structure tree. `object`/`array`
19
- * nest recursively, mirroring the graph's `DocumentModelJsonStructureInput`.
15
+ * A field in a JSON/XML file reader's structure tree. `object`/`array` nest
16
+ * recursively, mirroring the `structure`/`values` JSON-encoded attribute's
17
+ * shape (`{ properties: [...] }`).
20
18
  */
21
19
  export type JsonStructureField = {
22
20
  readonly type: "text";
@@ -47,78 +45,138 @@ export type JsonStructureField = {
47
45
  readonly name: string;
48
46
  readonly itemType: JsonStructureField;
49
47
  };
50
- /** An AI-extraction field definition. */
51
- export interface FileReaderAiField {
52
- readonly name: string;
53
- readonly description: string;
54
- readonly required: boolean;
55
- readonly type: string;
56
- }
57
- /** Where in the spreadsheet an Excel field's value lives. */
48
+ /** Where in the spreadsheet an Excel field's value lives (all 0-based). */
58
49
  export interface ExcelCellLocation {
59
50
  readonly sheet: number;
60
51
  readonly row: number;
61
52
  readonly column: number;
62
53
  }
63
- /** An Excel/Excel-cell field mapping. */
54
+ /** An Excel field mapping — a fixed cell location plus its extracted type. */
64
55
  export interface FileReaderExcelField {
56
+ readonly name: string;
57
+ /** e.g. "TEXT", "NUMBER", "DECIMAL", "BOOLEAN", "DATE", "DATETIME", "PICKLIST", "USER_ID", "GROUP_ID", "HTML", "LOCALIZATION_KEY", "UUID". */
58
+ readonly type: string;
59
+ readonly location: ExcelCellLocation;
60
+ /** Defaults to true on the platform. */
61
+ readonly include?: boolean;
62
+ /** Defaults to true on the platform. */
63
+ readonly required?: boolean;
64
+ }
65
+ interface FileReaderOptionsBase extends EntityDeployOptions {
66
+ readonly parent: string;
67
+ readonly name: string;
68
+ }
69
+ export interface FileReaderExcelOptions extends FileReaderOptionsBase {
70
+ readonly type: "excel";
71
+ readonly firstRowIsHeader: boolean;
72
+ readonly fields: readonly FileReaderExcelField[];
73
+ /**
74
+ * Base64 content of the sample spreadsheet `fields[].location` values are
75
+ * relative to. Required when creating a new resource (enforced by the
76
+ * provider at apply time, not by its schema); the platform never returns
77
+ * it back on read, so a pulled file reader can't reconstruct it — pull
78
+ * leaves this unset (matching the null state already on an imported
79
+ * resource) rather than fabricate a value that would plan a replace.
80
+ */
81
+ readonly documentContent?: string;
82
+ readonly documentName?: string;
83
+ readonly fileType?: string;
84
+ }
85
+ export interface FileReaderJsonOptions extends FileReaderOptionsBase {
86
+ readonly type: "json";
87
+ readonly structure: readonly JsonStructureField[];
88
+ }
89
+ export interface FileReaderTextOptions extends FileReaderOptionsBase {
90
+ readonly type: "text";
91
+ }
92
+ /**
93
+ * A field the AI file reader extracts. Named with an `AiFileReader-` prefix
94
+ * (not `FileReaderAi-`) to avoid colliding with the deprecated
95
+ * `FileReaderAiField`/`FileReaderAiOptions` legacy exports below, which keep
96
+ * their names for published API back-compat.
97
+ */
98
+ export interface AiFileReaderField {
99
+ readonly name: string;
100
+ readonly description: string;
101
+ /** e.g. "TEXT", "NUMBER", "DECIMAL", "BOOLEAN", "DATE", "DATETIME". */
102
+ readonly type: string;
103
+ /** Defaults to true on the platform. */
104
+ readonly required?: boolean;
105
+ }
106
+ export interface AiFileReaderOptions extends FileReaderOptionsBase {
107
+ readonly type: "ai";
108
+ readonly instructions: string;
109
+ readonly fields: readonly AiFileReaderField[];
110
+ }
111
+ export type FileReaderOptions = FileReaderExcelOptions | FileReaderJsonOptions | FileReaderTextOptions | AiFileReaderOptions;
112
+ /** The authored shape stored as `DeployableEntity.payload` — `FileReaderOptions` minus the deploy-only `parent`/`enabled`. */
113
+ export type FileReaderPayload = Omit<FileReaderExcelOptions, "parent" | "enabled"> | Omit<FileReaderJsonOptions, "parent" | "enabled"> | Omit<FileReaderTextOptions, "parent" | "enabled"> | Omit<AiFileReaderOptions, "parent" | "enabled">;
114
+ export interface FileReaderConfigured {
115
+ ref(refName: string): FileReaderCatalogRef;
116
+ def(refName: string): DeployableEntity;
117
+ }
118
+ export declare function defineFileReader(opts: FileReaderOptions): FileReaderConfigured;
119
+ import type { FileReaderCreateInput, FileReaderUpdateInput, InvoiceFieldLabel } from "../../../elementum-entity-client/clients/document-models/models/document-model.js";
120
+ /** @deprecated Pre-terraform API. An AI-extraction field definition. */
121
+ export interface FileReaderAiField {
122
+ readonly name: string;
123
+ readonly description: string;
124
+ readonly required: boolean;
125
+ readonly type: string;
126
+ }
127
+ /** @deprecated Pre-terraform API. An Excel/Excel-cell field mapping — renamed from `FileReaderExcelField` (now a different shape). */
128
+ export interface LegacyFileReaderExcelField {
65
129
  readonly name?: string;
66
130
  readonly fieldType: string;
67
131
  readonly required: boolean;
68
132
  readonly include: boolean;
69
133
  readonly location?: ExcelCellLocation;
70
134
  }
71
- interface FileReaderOptionsBase extends EntityDeployOptions {
72
- readonly parent: string;
73
- readonly name: string;
74
- }
135
+ /** @deprecated Pre-terraform API. */
75
136
  export interface FileReaderAiOptions extends FileReaderOptionsBase {
76
137
  readonly type: "ai";
77
138
  readonly instructions: string;
78
139
  readonly fields: readonly FileReaderAiField[];
79
140
  }
80
- export interface FileReaderExcelOptions extends FileReaderOptionsBase {
141
+ /** @deprecated Pre-terraform API. Renamed from `FileReaderExcelOptions` (now a different shape, targeting `elementum_excel_file_reader` directly). */
142
+ export interface LegacyFileReaderExcelOptions extends FileReaderOptionsBase {
81
143
  readonly type: "excel";
82
144
  readonly documentId: string;
83
145
  readonly firstRowIsHeader: boolean;
84
- readonly fields: readonly FileReaderExcelField[];
146
+ readonly fields: readonly LegacyFileReaderExcelField[];
85
147
  }
148
+ /** @deprecated Pre-terraform API. */
86
149
  export interface FileReaderExcelCellOptions extends FileReaderOptionsBase {
87
150
  readonly type: "excelCell";
88
151
  readonly documentId: string;
89
- readonly fields: readonly FileReaderExcelField[];
152
+ readonly fields: readonly LegacyFileReaderExcelField[];
90
153
  }
154
+ /** @deprecated Pre-terraform API. */
91
155
  export interface FileReaderInvoiceOptions extends FileReaderOptionsBase {
92
156
  readonly type: "invoice";
93
157
  readonly fields: readonly InvoiceFieldLabel[];
94
158
  }
95
- export interface FileReaderJsonOptions extends FileReaderOptionsBase {
96
- readonly type: "json";
97
- readonly structure: readonly JsonStructureField[];
98
- }
159
+ /** @deprecated Pre-terraform API. */
99
160
  export interface FileReaderOcrOptions extends FileReaderOptionsBase {
100
161
  readonly type: "ocr";
101
162
  }
163
+ /** @deprecated Pre-terraform API. */
102
164
  export interface FileReaderXmlOptions extends FileReaderOptionsBase {
103
165
  readonly type: "xml";
104
166
  readonly structure: readonly JsonStructureField[];
105
167
  }
106
- export type FileReaderOptions = FileReaderAiOptions | FileReaderExcelOptions | FileReaderExcelCellOptions | FileReaderInvoiceOptions | FileReaderJsonOptions | FileReaderOcrOptions | FileReaderXmlOptions;
107
- /** The authored shape stored as `DeployableEntity.payload` — `DocumentModelOptions` minus the deploy-only `parent`/`enabled`. */
108
- export type FileReaderPayload = Omit<FileReaderAiOptions, "parent" | "enabled"> | Omit<FileReaderExcelOptions, "parent" | "enabled"> | Omit<FileReaderExcelCellOptions, "parent" | "enabled"> | Omit<FileReaderInvoiceOptions, "parent" | "enabled"> | Omit<FileReaderJsonOptions, "parent" | "enabled"> | Omit<FileReaderOcrOptions, "parent" | "enabled"> | Omit<FileReaderXmlOptions, "parent" | "enabled">;
109
- /** Build the `documentModelCreate` mutation input from a document model's authored payload. */
110
- export declare function fileReaderCreateBody(opts: FileReaderPayload): FileReaderCreateInput;
168
+ /** @deprecated Pre-terraform API. Renamed from `FileReaderOptions` (now the terraform-facing union above). */
169
+ export type LegacyFileReaderOptions = FileReaderAiOptions | LegacyFileReaderExcelOptions | FileReaderExcelCellOptions | FileReaderInvoiceOptions | FileReaderJsonOptions | FileReaderOcrOptions | FileReaderXmlOptions;
170
+ /** @deprecated Pre-terraform API. Renamed from `FileReaderPayload` (now the terraform-facing union above). */
171
+ export type LegacyFileReaderPayload = Omit<FileReaderAiOptions, "parent" | "enabled"> | Omit<LegacyFileReaderExcelOptions, "parent" | "enabled"> | Omit<FileReaderExcelCellOptions, "parent" | "enabled"> | Omit<FileReaderInvoiceOptions, "parent" | "enabled"> | Omit<FileReaderJsonOptions, "parent" | "enabled"> | Omit<FileReaderOcrOptions, "parent" | "enabled"> | Omit<FileReaderXmlOptions, "parent" | "enabled">;
172
+ /** @deprecated Pre-terraform API. Build the `documentModelCreate` mutation input from a document model's authored payload. */
173
+ export declare function fileReaderCreateBody(opts: LegacyFileReaderPayload): FileReaderCreateInput;
111
174
  /**
112
- * Build the `documentModelUpdate` mutation input. `excelCell` has no update
113
- * path on the graph for its own content — only `name` — so
114
- * `isDocumentModelUpdateSupported` (`src/deploy/plan/plan.ts`) routes any
115
- * other excelCell change to `update-unsupported` before this is ever called
116
- * with excelCell content changes.
175
+ * @deprecated Pre-terraform API. Build the `documentModelUpdate` mutation
176
+ * input. `excelCell` has no update path on the graph for its own content —
177
+ * only `name` — so callers must route any other excelCell change to
178
+ * update-unsupported themselves before calling this with excelCell content
179
+ * changes.
117
180
  */
118
- export declare function fileReaderUpdateBody(opts: FileReaderPayload): FileReaderUpdateInput;
119
- export interface FileReaderConfigured {
120
- ref(refName: string): FileReaderCatalogRef;
121
- def(refName: string): DeployableEntity;
122
- }
123
- export declare function defineFileReader(opts: FileReaderOptions): FileReaderConfigured;
181
+ export declare function fileReaderUpdateBody(opts: LegacyFileReaderPayload): FileReaderUpdateInput;
124
182
  export {};
@@ -1,3 +1,20 @@
1
+ export function defineFileReader(opts) {
2
+ return {
3
+ ref(refName) {
4
+ return { __kind: "documentModel", refName, name: opts.name, parent: opts.parent, readerType: opts.type };
5
+ },
6
+ def(refName) {
7
+ const { parent, enabled, ...payload } = opts;
8
+ return {
9
+ kind: "documentModel",
10
+ parent,
11
+ refName,
12
+ payload,
13
+ ...(enabled !== undefined ? { enabled } : {}),
14
+ };
15
+ },
16
+ };
17
+ }
1
18
  function serializeJsonStructureField(f) {
2
19
  switch (f.type) {
3
20
  case "text":
@@ -33,7 +50,7 @@ function serializeExcelFields(fields) {
33
50
  ...(f.location !== undefined ? { location: f.location } : {}),
34
51
  }));
35
52
  }
36
- /** Build the `documentModelCreate` mutation input from a document model's authored payload. */
53
+ /** @deprecated Pre-terraform API. Build the `documentModelCreate` mutation input from a document model's authored payload. */
37
54
  export function fileReaderCreateBody(opts) {
38
55
  switch (opts.type) {
39
56
  case "ai":
@@ -62,11 +79,11 @@ export function fileReaderCreateBody(opts) {
62
79
  }
63
80
  }
64
81
  /**
65
- * Build the `documentModelUpdate` mutation input. `excelCell` has no update
66
- * path on the graph for its own content — only `name` — so
67
- * `isDocumentModelUpdateSupported` (`src/deploy/plan/plan.ts`) routes any
68
- * other excelCell change to `update-unsupported` before this is ever called
69
- * with excelCell content changes.
82
+ * @deprecated Pre-terraform API. Build the `documentModelUpdate` mutation
83
+ * input. `excelCell` has no update path on the graph for its own content —
84
+ * only `name` — so callers must route any other excelCell change to
85
+ * update-unsupported themselves before calling this with excelCell content
86
+ * changes.
70
87
  */
71
88
  export function fileReaderUpdateBody(opts) {
72
89
  switch (opts.type) {
@@ -86,20 +103,3 @@ export function fileReaderUpdateBody(opts) {
86
103
  return { name: opts.name, xml: { name: opts.name, values: serializeJsonStructure(opts.structure) } };
87
104
  }
88
105
  }
89
- export function defineFileReader(opts) {
90
- return {
91
- ref(refName) {
92
- return { __kind: "documentModel", refName, name: opts.name, parent: opts.parent };
93
- },
94
- def(refName) {
95
- const { parent, enabled, ...payload } = opts;
96
- return {
97
- kind: "documentModel",
98
- parent,
99
- refName,
100
- payload,
101
- ...(enabled !== undefined ? { enabled } : {}),
102
- };
103
- },
104
- };
105
- }
@@ -0,0 +1,6 @@
1
+ import type { NormalizedFileReader } from "../from-tf.js";
2
+ export interface PrintFileReaderOptions {
3
+ /** The owning app's refName — the file's `parent` option. */
4
+ readonly parent: string;
5
+ }
6
+ export declare function printFileReader(model: NormalizedFileReader, opts: PrintFileReaderOptions): string;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * `NormalizedFileReader` → editable `defineFileReader({...})` source, a
3
+ * configured `{ ref, def }` builder call exported as default — same
4
+ * convention as the other configured-builder printers (`print-skill-v2.ts`,
5
+ * `print-agent.ts`). File readers carry no catalog-token references of their
6
+ * own (`parent` is a plain refName string), so this needs no `ImportTracker`.
7
+ */
8
+ import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
9
+ export function printFileReader(model, opts) {
10
+ const { payload } = model;
11
+ const lines = [];
12
+ lines.push(`/**`);
13
+ lines.push(` * Auto-generated by EDK (pull). Hand-edit freely; the generator is a`);
14
+ lines.push(` * one-shot starting point, not a live-binding view.`);
15
+ lines.push(` */`);
16
+ lines.push("");
17
+ lines.push(`import { defineFileReader } from "${sdkPackageSpecifier("fileReaders")}";`);
18
+ lines.push("");
19
+ lines.push(`const fileReader = defineFileReader({`);
20
+ lines.push(` type: ${quote(payload.type)},`);
21
+ lines.push(` name: ${quote(payload.name)},`);
22
+ lines.push(` parent: ${quote(opts.parent)},`);
23
+ const body = printBody(payload);
24
+ if (body.length > 0)
25
+ lines.push(body);
26
+ lines.push(`});`);
27
+ lines.push("");
28
+ lines.push(`export default fileReader;`);
29
+ return lines.join("\n") + "\n";
30
+ }
31
+ function printBody(payload) {
32
+ switch (payload.type) {
33
+ case "excel":
34
+ return [
35
+ ` firstRowIsHeader: ${payload.firstRowIsHeader},`,
36
+ ` fields: ${printExcelFields(payload.fields)},`,
37
+ // documentContent/documentName/fileType are never recoverable from
38
+ // the platform (its own schema docs say so - Read() never returns
39
+ // any of the three on an already-imported resource), so pull never
40
+ // sets them: only needed to CREATE a genuinely new Excel reader, e.g.
41
+ // documentContent: filebase64("path/to/sample.xlsx"),
42
+ // documentName: "sample.xlsx",
43
+ // fileType: "xlsx",
44
+ ...(payload.documentContent !== undefined ? [` documentContent: ${quote(payload.documentContent)},`] : []),
45
+ ...(payload.documentName !== undefined ? [` documentName: ${quote(payload.documentName)},`] : []),
46
+ ...(payload.fileType !== undefined ? [` fileType: ${quote(payload.fileType)},`] : []),
47
+ ].join("\n");
48
+ case "json":
49
+ return ` structure: ${printStructure(payload.structure, 1)},`;
50
+ case "text":
51
+ return "";
52
+ case "ai":
53
+ return [
54
+ ` instructions: ${quote(payload.instructions)},`,
55
+ ` fields: ${printAiFields(payload.fields)},`,
56
+ ].join("\n");
57
+ }
58
+ }
59
+ function printAiFields(fields) {
60
+ if (fields.length === 0)
61
+ return "[]";
62
+ const items = fields.map((f) => {
63
+ const parts = [`name: ${quote(f.name)}`, `description: ${quote(f.description)}`, `type: ${quote(f.type)}`];
64
+ if (f.required !== undefined)
65
+ parts.push(`required: ${f.required}`);
66
+ return `{ ${parts.join(", ")} }`;
67
+ });
68
+ return `[\n ${items.join(",\n ")},\n ]`;
69
+ }
70
+ function printExcelFields(fields) {
71
+ if (fields.length === 0)
72
+ return "[]";
73
+ const items = fields.map((f) => {
74
+ const parts = [`name: ${quote(f.name)}`, `type: ${quote(f.type)}`, `location: { sheet: ${f.location.sheet}, row: ${f.location.row}, column: ${f.location.column} }`];
75
+ if (f.include !== undefined)
76
+ parts.push(`include: ${f.include}`);
77
+ if (f.required !== undefined)
78
+ parts.push(`required: ${f.required}`);
79
+ return `{ ${parts.join(", ")} }`;
80
+ });
81
+ return `[\n ${items.join(",\n ")},\n ]`;
82
+ }
83
+ function printStructure(fields, indent) {
84
+ if (fields.length === 0)
85
+ return "[]";
86
+ const pad = " ".repeat(indent + 1);
87
+ const closePad = " ".repeat(indent);
88
+ const items = fields.map((f) => printStructureField(f, indent + 1));
89
+ return `[\n${pad}${items.join(`,\n${pad}`)},\n${closePad}]`;
90
+ }
91
+ function printStructureField(f, indent) {
92
+ switch (f.type) {
93
+ case "text":
94
+ case "number":
95
+ case "decimal":
96
+ case "boolean":
97
+ return `{ type: ${quote(f.type)}, name: ${quote(f.name)} }`;
98
+ case "date":
99
+ case "datetime":
100
+ return `{ type: ${quote(f.type)}, name: ${quote(f.name)}, format: ${quote(f.format)} }`;
101
+ case "object":
102
+ return `{ type: "object", name: ${quote(f.name)}, properties: ${printStructure(f.properties, indent)} }`;
103
+ case "array":
104
+ return `{ type: "array", name: ${quote(f.name)}, itemType: ${printStructureField(f.itemType, indent)} }`;
105
+ }
106
+ }
107
+ function quote(s) {
108
+ return JSON.stringify(s);
109
+ }
@@ -0,0 +1,13 @@
1
+ import type { FromTfContext } from "../../engine/pull/context.js";
2
+ import { type TfBlock } from "../../engine/tf/index.js";
3
+ import type { FileReaderPayload } from "./build.js";
4
+ export interface NormalizedFileReader {
5
+ readonly refName: string;
6
+ readonly payload: FileReaderPayload;
7
+ }
8
+ export interface FileReaderFromTfResult {
9
+ readonly fileReader?: NormalizedFileReader;
10
+ /** Set when this block can't be authored on the terraform path — reported, not fatal (plan §6). */
11
+ readonly skippedReason?: string;
12
+ }
13
+ export declare function fileReaderFromTf(block: TfBlock, appTfLabel: string, _ctx: FromTfContext): FileReaderFromTfResult;
@@ -0,0 +1,172 @@
1
+ /**
2
+ * `elementum_excel_file_reader` / `elementum_json_file_reader` /
3
+ * `elementum_text_file_reader` → `FileReaderPayload` (see `build.ts`). One
4
+ * `.ts` file per instance, own-file like skills — `module.ts` wires
5
+ * `extractOwnFile` per app-owned file reader block.
6
+ */
7
+ import { EntityTfError } from "../../engine/entity.js";
8
+ import { isTfExpr, scopedLabelToBagKey } from "../../engine/tf/index.js";
9
+ import { FILE_READER_SUB_TYPE_BY_RESOURCE } from "./types.js";
10
+ function isObject(value) {
11
+ return value !== null && typeof value === "object" && !Array.isArray(value) && !("$expr" in value);
12
+ }
13
+ const KNOWN_EXCEL_ATTRS = new Set([
14
+ "app_id", "name", "first_row_is_header", "document_content", "document_name", "file_type", "fields",
15
+ ]);
16
+ const KNOWN_JSON_ATTRS = new Set(["app_id", "name", "structure"]);
17
+ const KNOWN_TEXT_ATTRS = new Set(["app_id", "name"]);
18
+ const KNOWN_AI_ATTRS = new Set(["app_id", "name", "instructions", "fields"]);
19
+ function assertAllowed(block, allowed) {
20
+ for (const key of Object.keys(block.attrs)) {
21
+ if (!allowed.has(key)) {
22
+ throw new EntityTfError(`${block.type}.${block.label}: unrecognized attribute "${key}" — this EDK version doesn't know how to round-trip it`);
23
+ }
24
+ }
25
+ }
26
+ function decodeJson(value) {
27
+ if (isTfExpr(value)) {
28
+ if (value.$expr === "jsonencode")
29
+ return decodeJson(value.value);
30
+ throw new EntityTfError(`unsupported expression "${value.$expr}" inside a file reader's structure`);
31
+ }
32
+ if (Array.isArray(value))
33
+ return value.map(decodeJson);
34
+ if (isObject(value))
35
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, decodeJson(v)]));
36
+ return value;
37
+ }
38
+ function parseStructureField(node, where) {
39
+ if (!isObject(node))
40
+ throw new EntityTfError(`${where}: invalid structure node`);
41
+ const [type, body] = Object.entries(node)[0] ?? [];
42
+ if (type === undefined || !isObject(body) || typeof body.name !== "string") {
43
+ throw new EntityTfError(`${where}: invalid structure node`);
44
+ }
45
+ switch (type) {
46
+ case "text":
47
+ case "number":
48
+ case "decimal":
49
+ case "bool": {
50
+ const kind = type === "bool" ? "boolean" : type;
51
+ return { type: kind, name: body.name };
52
+ }
53
+ case "date":
54
+ case "datetime": {
55
+ if (typeof body.format !== "string")
56
+ throw new EntityTfError(`${where}: "${body.name}" is missing its date format`);
57
+ return { type, name: body.name, format: body.format };
58
+ }
59
+ case "object": {
60
+ const properties = Array.isArray(body.properties) ? body.properties : [];
61
+ return { type: "object", name: body.name, properties: properties.map((p) => parseStructureField(p, where)) };
62
+ }
63
+ case "array": {
64
+ if (body.arrayType === undefined)
65
+ throw new EntityTfError(`${where}: "${body.name}" is missing its arrayType`);
66
+ return { type: "array", name: body.name, itemType: parseStructureField(body.arrayType, where) };
67
+ }
68
+ default:
69
+ throw new EntityTfError(`${where}: unsupported structure node type "${type}"`);
70
+ }
71
+ }
72
+ function parseStructure(raw, where) {
73
+ if (!isObject(raw) || !Array.isArray(raw.properties))
74
+ throw new EntityTfError(`${where}: invalid structure`);
75
+ return raw.properties.map((p) => parseStructureField(p, where));
76
+ }
77
+ function parseExcelFields(value, where) {
78
+ if (!Array.isArray(value))
79
+ throw new EntityTfError(`${where}: "fields" must be an array`);
80
+ return value.map((item) => {
81
+ if (!isObject(item) || typeof item.name !== "string" || typeof item.type !== "string") {
82
+ throw new EntityTfError(`${where}: invalid field entry`);
83
+ }
84
+ const location = item.location;
85
+ if (!isObject(location) || typeof location.column !== "number" || typeof location.row !== "number" || typeof location.sheet !== "number") {
86
+ throw new EntityTfError(`${where}: field "${item.name}" is missing its cell location`);
87
+ }
88
+ return {
89
+ name: item.name,
90
+ type: item.type,
91
+ location: { column: location.column, row: location.row, sheet: location.sheet },
92
+ ...(typeof item.include === "boolean" ? { include: item.include } : {}),
93
+ ...(typeof item.required === "boolean" ? { required: item.required } : {}),
94
+ };
95
+ });
96
+ }
97
+ function parseAiFields(value, where) {
98
+ if (!Array.isArray(value))
99
+ throw new EntityTfError(`${where}: "fields" must be an array`);
100
+ return value.map((item) => {
101
+ if (!isObject(item) || typeof item.name !== "string" || typeof item.description !== "string" || typeof item.type !== "string") {
102
+ throw new EntityTfError(`${where}: invalid field entry`);
103
+ }
104
+ return {
105
+ name: item.name,
106
+ description: item.description,
107
+ type: item.type,
108
+ ...(typeof item.required === "boolean" ? { required: item.required } : {}),
109
+ };
110
+ });
111
+ }
112
+ export function fileReaderFromTf(block, appTfLabel, _ctx) {
113
+ const label = block.label;
114
+ if (label === undefined || label === "")
115
+ throw new EntityTfError(`${block.type} block is missing its label`);
116
+ const subType = FILE_READER_SUB_TYPE_BY_RESOURCE.get(block.type ?? "");
117
+ if (subType === undefined)
118
+ throw new EntityTfError(`unknown file reader resource type "${block.type}"`);
119
+ if (subType.implemented !== true) {
120
+ return { skippedReason: `${block.type}.${label}: ${subType.typeKey} file readers are not yet supported` };
121
+ }
122
+ const attrs = block.attrs;
123
+ const name = typeof attrs.name === "string" ? attrs.name : undefined;
124
+ if (name === undefined)
125
+ throw new EntityTfError(`${block.type}.${label}: "name" is required`);
126
+ const refName = scopedLabelToBagKey(appTfLabel, label);
127
+ const where = `${block.type}.${label}`;
128
+ if (subType.typeKey === "excel") {
129
+ assertAllowed(block, KNOWN_EXCEL_ATTRS);
130
+ if (typeof attrs.first_row_is_header !== "boolean")
131
+ throw new EntityTfError(`${where}: "first_row_is_header" is required`);
132
+ const fields = parseExcelFields(attrs.fields ?? [], where);
133
+ // document_content/document_name/file_type are never returned by
134
+ // Read() on an already-imported resource (the provider's schema docs
135
+ // say so), yet ei's export still emits placeholders for them - even
136
+ // document_content's empty-string placeholder counts as a change on
137
+ // this always-forces-replacement attribute, so reproducing any of the
138
+ // three plans a spurious destroy+recreate. Never extract them; the
139
+ // printer leaves a comment for anyone authoring a genuinely NEW reader.
140
+ // Adoption separately strips these placeholders from `.tf/in/` itself
141
+ // (stripUnrecoverableExcelFileReaderAttrs in engine/adopt/adopt.ts),
142
+ // since its gate plans against ei's raw export, not this extractor.
143
+ return {
144
+ fileReader: {
145
+ refName,
146
+ payload: {
147
+ type: "excel",
148
+ name,
149
+ firstRowIsHeader: attrs.first_row_is_header,
150
+ fields,
151
+ },
152
+ },
153
+ };
154
+ }
155
+ if (subType.typeKey === "json") {
156
+ assertAllowed(block, KNOWN_JSON_ATTRS);
157
+ if (attrs.structure === undefined)
158
+ throw new EntityTfError(`${where}: "structure" is required`);
159
+ const structure = parseStructure(decodeJson(attrs.structure), where);
160
+ return { fileReader: { refName, payload: { type: "json", name, structure } } };
161
+ }
162
+ if (subType.typeKey === "ai") {
163
+ assertAllowed(block, KNOWN_AI_ATTRS);
164
+ if (typeof attrs.instructions !== "string")
165
+ throw new EntityTfError(`${where}: "instructions" is required`);
166
+ const fields = parseAiFields(attrs.fields ?? [], where);
167
+ return { fileReader: { refName, payload: { type: "ai", name, instructions: attrs.instructions, fields } } };
168
+ }
169
+ // text
170
+ assertAllowed(block, KNOWN_TEXT_ATTRS);
171
+ return { fileReader: { refName, payload: { type: "text", name } } };
172
+ }
@@ -1,5 +1,10 @@
1
1
  /**
2
- * Document model authoring — create/edit AI, Excel, Excel-cell, invoice,
3
- * JSON, OCR, and XML document models.
2
+ * File-reader authoring — create/edit Excel, JSON, and text (OCR) file
3
+ * readers, referenced by an automation's `readFile` task.
4
+ *
5
+ * The `Legacy*`/`@deprecated` exports below are the pre-terraform,
6
+ * GraphQL-mutation-based API this file replaced — kept for published
7
+ * `@elementumai/edk/fileReaders` API back-compat only, not used by
8
+ * `elementum build`/`pull`. See `build.ts`'s "Legacy" section doc comment.
4
9
  */
5
- export { defineFileReader, fileReaderCreateBody, fileReaderUpdateBody, type FileReaderAiField, type FileReaderAiOptions, type FileReaderConfigured, type FileReaderExcelCellOptions, type FileReaderExcelField, type FileReaderExcelOptions, type FileReaderInvoiceOptions, type FileReaderJsonOptions, type FileReaderOcrOptions, type FileReaderOptions, type FileReaderPayload, type FileReaderXmlOptions, type ExcelCellLocation, type JsonStructureField, } from "./build.js";
10
+ export { defineFileReader, type AiFileReaderField, type AiFileReaderOptions, type ExcelCellLocation, type FileReaderConfigured, type FileReaderExcelField, type FileReaderExcelOptions, type FileReaderJsonOptions, type FileReaderOptions, type FileReaderPayload, type FileReaderTextOptions, type JsonStructureField, fileReaderCreateBody, fileReaderUpdateBody, type FileReaderAiField, type FileReaderAiOptions, type FileReaderExcelCellOptions, type FileReaderInvoiceOptions, type FileReaderOcrOptions, type FileReaderXmlOptions, type LegacyFileReaderExcelField, type LegacyFileReaderExcelOptions, type LegacyFileReaderOptions, type LegacyFileReaderPayload, } from "./build.js";
@@ -1,5 +1,10 @@
1
1
  /**
2
- * Document model authoring — create/edit AI, Excel, Excel-cell, invoice,
3
- * JSON, OCR, and XML document models.
2
+ * File-reader authoring — create/edit Excel, JSON, and text (OCR) file
3
+ * readers, referenced by an automation's `readFile` task.
4
+ *
5
+ * The `Legacy*`/`@deprecated` exports below are the pre-terraform,
6
+ * GraphQL-mutation-based API this file replaced — kept for published
7
+ * `@elementumai/edk/fileReaders` API back-compat only, not used by
8
+ * `elementum build`/`pull`. See `build.ts`'s "Legacy" section doc comment.
4
9
  */
5
10
  export { defineFileReader, fileReaderCreateBody, fileReaderUpdateBody, } from "./build.js";
@@ -0,0 +1,3 @@
1
+ /** The file-reader entity's registry entry (see src/graph/). */
2
+ import { type EntityKindModule } from "../../graph/types.js";
3
+ export declare const fileReaderModule: EntityKindModule;