@atmyapp/cli 0.0.1 → 0.0.2

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.
@@ -126,7 +126,7 @@ function extractDefinitionTypes(atmyappType, logger) {
126
126
  }
127
127
  // Processes an ATMYAPP export to extract content definitions
128
128
  function processAtmyappExport(atmyappType, file, tsconfigPath, logger) {
129
- var _a, _b;
129
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
130
130
  const contents = [];
131
131
  logger.verbose_log(`Processing ATMYAPP export in ${file.getFilePath()}`);
132
132
  // Extract individual definition types from the array
@@ -169,39 +169,90 @@ function processAtmyappExport(atmyappType, file, tsconfigPath, logger) {
169
169
  continue;
170
170
  }
171
171
  const properties = schema.properties;
172
- // Extract path from AmaContentRef structure
173
- let path = null;
174
- let structure = null;
175
- // Look for path in different possible locations
176
- if ((_a = properties.path) === null || _a === void 0 ? void 0 : _a.const) {
177
- path = properties.path.const;
178
- }
179
- else if ((_b = properties._path) === null || _b === void 0 ? void 0 : _b.const) {
180
- path = properties._path.const;
181
- }
182
- // Look for structure/data in different possible locations
183
- if (properties.structure) {
184
- structure = properties.structure;
185
- }
186
- else if (properties.data) {
187
- structure = properties.data;
188
- }
189
- else if (properties._data) {
190
- structure = properties._data;
191
- }
192
- if (!path) {
193
- logger.warn(`Could not extract path from ${definitionType}`);
194
- continue;
172
+ // Check if this is an event definition
173
+ const isEventDef = ((_a = properties.type) === null || _a === void 0 ? void 0 : _a.const) === "event" ||
174
+ (((_b = properties.__is_ATMYAPP_Object) === null || _b === void 0 ? void 0 : _b.const) === true &&
175
+ properties.id &&
176
+ properties.columns);
177
+ if (isEventDef) {
178
+ // Handle AmaEventDef - use id as path and extract event structure
179
+ let eventId = null;
180
+ let columns = [];
181
+ // Extract event ID
182
+ if ((_c = properties.id) === null || _c === void 0 ? void 0 : _c.const) {
183
+ eventId = properties.id.const;
184
+ }
185
+ // Extract columns
186
+ if ((_d = properties.columns) === null || _d === void 0 ? void 0 : _d.const) {
187
+ columns = properties.columns.const;
188
+ }
189
+ else if ((_f = (_e = properties.columns) === null || _e === void 0 ? void 0 : _e.items) === null || _f === void 0 ? void 0 : _f.const) {
190
+ columns = properties.columns.items.const;
191
+ }
192
+ else if (((_g = properties.columns) === null || _g === void 0 ? void 0 : _g.items) &&
193
+ Array.isArray(properties.columns.items)) {
194
+ // Handle array of const items - extract const value from each item
195
+ columns = properties.columns.items
196
+ .map((item) => item.const)
197
+ .filter(Boolean);
198
+ }
199
+ if (!eventId) {
200
+ logger.warn(`Could not extract event ID from ${definitionType}`);
201
+ continue;
202
+ }
203
+ if (columns.length === 0) {
204
+ logger.warn(`Could not extract columns from ${definitionType}`);
205
+ continue;
206
+ }
207
+ logger.verbose_log(`Successfully extracted event: ${eventId} with columns: ${columns.join(", ")}`);
208
+ // Create event content with special structure
209
+ contents.push({
210
+ path: eventId, // Use event ID as path
211
+ structure: {
212
+ type: "event",
213
+ properties: {
214
+ id: { const: eventId },
215
+ columns: { const: columns },
216
+ type: { const: "event" },
217
+ },
218
+ },
219
+ });
195
220
  }
196
- if (!structure) {
197
- logger.warn(`Could not extract structure from ${definitionType}`);
198
- continue;
221
+ else {
222
+ // Handle regular AmaContentDef - extract path and structure
223
+ let path = null;
224
+ let structure = null;
225
+ // Look for path in different possible locations
226
+ if ((_h = properties.path) === null || _h === void 0 ? void 0 : _h.const) {
227
+ path = properties.path.const;
228
+ }
229
+ else if ((_j = properties._path) === null || _j === void 0 ? void 0 : _j.const) {
230
+ path = properties._path.const;
231
+ }
232
+ // Look for structure/data in different possible locations
233
+ if (properties.structure) {
234
+ structure = properties.structure;
235
+ }
236
+ else if (properties.data) {
237
+ structure = properties.data;
238
+ }
239
+ else if (properties._data) {
240
+ structure = properties._data;
241
+ }
242
+ if (!path) {
243
+ logger.warn(`Could not extract path from ${definitionType}`);
244
+ continue;
245
+ }
246
+ if (!structure) {
247
+ logger.warn(`Could not extract structure from ${definitionType}`);
248
+ continue;
249
+ }
250
+ logger.verbose_log(`Successfully extracted content: ${path}`);
251
+ contents.push({
252
+ path,
253
+ structure,
254
+ });
199
255
  }
200
- logger.verbose_log(`Successfully extracted content: ${path}`);
201
- contents.push({
202
- path,
203
- structure,
204
- });
205
256
  }
206
257
  catch (err) {
207
258
  logger.error(`Error processing definition type ${definitionType}:`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmyapp/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {