@wix/ditto-codegen-public 1.0.81 → 1.0.83

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 (2) hide show
  1. package/dist/out.js +567 -15
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -117225,22 +117225,27 @@ var require_PlannerAgent = __commonJS({
117225
117225
  buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions) {
117226
117226
  return (0, planner_1.plannerPrompt)(hasEmbeddedScriptExtensions, hasBackendApiExtensions);
117227
117227
  }
117228
- async generate(blueprint) {
117228
+ async generatePlan(systemPrompt, blueprint, error) {
117229
117229
  const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
117230
- const hasEmbeddedScriptExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
117231
- const hasBackendApiExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.BACKEND_API) ?? false;
117230
+ const userContent = `
117231
+ ${JSON.stringify(blueprint, null, 2)}
117232
+ ${error ? `
117233
+
117234
+ The previous attempt failed with the following error:
117235
+ ${error}` : ""}
117236
+ `;
117232
117237
  const result = await (0, ai_1.generateObject)({
117233
117238
  model,
117234
117239
  schema: exports2.PlannerOutputSchema,
117235
117240
  messages: [
117236
117241
  {
117237
117242
  role: "system",
117238
- content: this.buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions),
117243
+ content: systemPrompt,
117239
117244
  providerOptions: (0, utils_1.withCaching)("1h")
117240
117245
  },
117241
117246
  {
117242
117247
  role: "user",
117243
- content: JSON.stringify(blueprint ?? {}, null, 2)
117248
+ content: userContent
117244
117249
  }
117245
117250
  ],
117246
117251
  maxRetries: 3,
@@ -117252,6 +117257,23 @@ var require_PlannerAgent = __commonJS({
117252
117257
  });
117253
117258
  return result.object;
117254
117259
  }
117260
+ async generate(blueprint) {
117261
+ const hasEmbeddedScriptExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
117262
+ const hasBackendApiExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.BACKEND_API) ?? false;
117263
+ const systemPrompt = this.buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions);
117264
+ let lastError;
117265
+ for (let i = 0; i < 3; i++) {
117266
+ try {
117267
+ const result = await this.generatePlan(systemPrompt, blueprint, lastError);
117268
+ return result;
117269
+ } catch (error) {
117270
+ lastError = JSON.stringify(error);
117271
+ console.error(`Error generating plan (attempt ${i + 1}): ${error}`);
117272
+ continue;
117273
+ }
117274
+ }
117275
+ throw new Error("Failed to generate plan after 3 attempts");
117276
+ }
117255
117277
  };
117256
117278
  exports2.PlannerAgent = PlannerAgent;
117257
117279
  exports2.default = PlannerAgent;
@@ -130375,6 +130397,528 @@ var require_file_collector = __commonJS({
130375
130397
  }
130376
130398
  });
130377
130399
 
130400
+ // ../../node_modules/javascript-stringify/dist/quote.js
130401
+ var require_quote = __commonJS({
130402
+ "../../node_modules/javascript-stringify/dist/quote.js"(exports2) {
130403
+ "use strict";
130404
+ Object.defineProperty(exports2, "__esModule", { value: true });
130405
+ exports2.stringifyPath = exports2.quoteKey = exports2.isValidVariableName = exports2.IS_VALID_IDENTIFIER = exports2.quoteString = void 0;
130406
+ var ESCAPABLE = /[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
130407
+ var META_CHARS = /* @__PURE__ */ new Map([
130408
+ ["\b", "\\b"],
130409
+ [" ", "\\t"],
130410
+ ["\n", "\\n"],
130411
+ ["\f", "\\f"],
130412
+ ["\r", "\\r"],
130413
+ ["'", "\\'"],
130414
+ ['"', '\\"'],
130415
+ ["\\", "\\\\"]
130416
+ ]);
130417
+ function escapeChar(char) {
130418
+ return META_CHARS.get(char) || `\\u${`0000${char.charCodeAt(0).toString(16)}`.slice(-4)}`;
130419
+ }
130420
+ function quoteString(str) {
130421
+ return `'${str.replace(ESCAPABLE, escapeChar)}'`;
130422
+ }
130423
+ exports2.quoteString = quoteString;
130424
+ var RESERVED_WORDS = new Set("break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "));
130425
+ exports2.IS_VALID_IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
130426
+ function isValidVariableName(name) {
130427
+ return typeof name === "string" && !RESERVED_WORDS.has(name) && exports2.IS_VALID_IDENTIFIER.test(name);
130428
+ }
130429
+ exports2.isValidVariableName = isValidVariableName;
130430
+ function quoteKey(key, next) {
130431
+ return isValidVariableName(key) ? key : next(key);
130432
+ }
130433
+ exports2.quoteKey = quoteKey;
130434
+ function stringifyPath(path2, next) {
130435
+ let result = "";
130436
+ for (const key of path2) {
130437
+ if (isValidVariableName(key)) {
130438
+ result += `.${key}`;
130439
+ } else {
130440
+ result += `[${next(key)}]`;
130441
+ }
130442
+ }
130443
+ return result;
130444
+ }
130445
+ exports2.stringifyPath = stringifyPath;
130446
+ }
130447
+ });
130448
+
130449
+ // ../../node_modules/javascript-stringify/dist/function.js
130450
+ var require_function = __commonJS({
130451
+ "../../node_modules/javascript-stringify/dist/function.js"(exports2) {
130452
+ "use strict";
130453
+ Object.defineProperty(exports2, "__esModule", { value: true });
130454
+ exports2.FunctionParser = exports2.dedentFunction = exports2.functionToString = exports2.USED_METHOD_KEY = void 0;
130455
+ var quote_1 = require_quote();
130456
+ var METHOD_NAMES_ARE_QUOTED = {
130457
+ " "() {
130458
+ }
130459
+ }[" "].toString().charAt(0) === '"';
130460
+ var FUNCTION_PREFIXES = {
130461
+ Function: "function ",
130462
+ GeneratorFunction: "function* ",
130463
+ AsyncFunction: "async function ",
130464
+ AsyncGeneratorFunction: "async function* "
130465
+ };
130466
+ var METHOD_PREFIXES = {
130467
+ Function: "",
130468
+ GeneratorFunction: "*",
130469
+ AsyncFunction: "async ",
130470
+ AsyncGeneratorFunction: "async *"
130471
+ };
130472
+ var TOKENS_PRECEDING_REGEXPS = new Set("case delete else in instanceof new return throw typeof void , ; : + - ! ~ & | ^ * / % < > ? =".split(" "));
130473
+ exports2.USED_METHOD_KEY = /* @__PURE__ */ new WeakSet();
130474
+ var functionToString = (fn, space, next, key) => {
130475
+ const name = typeof key === "string" ? key : void 0;
130476
+ if (name !== void 0)
130477
+ exports2.USED_METHOD_KEY.add(fn);
130478
+ return new FunctionParser(fn, space, next, name).stringify();
130479
+ };
130480
+ exports2.functionToString = functionToString;
130481
+ function dedentFunction(fnString) {
130482
+ let found;
130483
+ for (const line of fnString.split("\n").slice(1)) {
130484
+ const m = /^[\s\t]+/.exec(line);
130485
+ if (!m)
130486
+ return fnString;
130487
+ const [str] = m;
130488
+ if (found === void 0)
130489
+ found = str;
130490
+ else if (str.length < found.length)
130491
+ found = str;
130492
+ }
130493
+ return found ? fnString.split(`
130494
+ ${found}`).join("\n") : fnString;
130495
+ }
130496
+ exports2.dedentFunction = dedentFunction;
130497
+ var FunctionParser = class {
130498
+ constructor(fn, indent, next, key) {
130499
+ this.fn = fn;
130500
+ this.indent = indent;
130501
+ this.next = next;
130502
+ this.key = key;
130503
+ this.pos = 0;
130504
+ this.hadKeyword = false;
130505
+ this.fnString = Function.prototype.toString.call(fn);
130506
+ this.fnType = fn.constructor.name;
130507
+ this.keyQuote = key === void 0 ? "" : quote_1.quoteKey(key, next);
130508
+ this.keyPrefix = key === void 0 ? "" : `${this.keyQuote}:${indent ? " " : ""}`;
130509
+ this.isMethodCandidate = key === void 0 ? false : this.fn.name === "" || this.fn.name === key;
130510
+ }
130511
+ stringify() {
130512
+ const value = this.tryParse();
130513
+ if (!value) {
130514
+ return `${this.keyPrefix}void ${this.next(this.fnString)}`;
130515
+ }
130516
+ return dedentFunction(value);
130517
+ }
130518
+ getPrefix() {
130519
+ if (this.isMethodCandidate && !this.hadKeyword) {
130520
+ return METHOD_PREFIXES[this.fnType] + this.keyQuote;
130521
+ }
130522
+ return this.keyPrefix + FUNCTION_PREFIXES[this.fnType];
130523
+ }
130524
+ tryParse() {
130525
+ if (this.fnString[this.fnString.length - 1] !== "}") {
130526
+ return this.keyPrefix + this.fnString;
130527
+ }
130528
+ if (this.fn.name) {
130529
+ const result = this.tryStrippingName();
130530
+ if (result)
130531
+ return result;
130532
+ }
130533
+ const prevPos = this.pos;
130534
+ if (this.consumeSyntax() === "class")
130535
+ return this.fnString;
130536
+ this.pos = prevPos;
130537
+ if (this.tryParsePrefixTokens()) {
130538
+ const result = this.tryStrippingName();
130539
+ if (result)
130540
+ return result;
130541
+ let offset = this.pos;
130542
+ switch (this.consumeSyntax("WORD_LIKE")) {
130543
+ case "WORD_LIKE":
130544
+ if (this.isMethodCandidate && !this.hadKeyword) {
130545
+ offset = this.pos;
130546
+ }
130547
+ case "()":
130548
+ if (this.fnString.substr(this.pos, 2) === "=>") {
130549
+ return this.keyPrefix + this.fnString;
130550
+ }
130551
+ this.pos = offset;
130552
+ case '"':
130553
+ case "'":
130554
+ case "[]":
130555
+ return this.getPrefix() + this.fnString.substr(this.pos);
130556
+ }
130557
+ }
130558
+ }
130559
+ /**
130560
+ * Attempt to parse the function from the current position by first stripping
130561
+ * the function's name from the front. This is not a fool-proof method on all
130562
+ * JavaScript engines, but yields good results on Node.js 4 (and slightly
130563
+ * less good results on Node.js 6 and 8).
130564
+ */
130565
+ tryStrippingName() {
130566
+ if (METHOD_NAMES_ARE_QUOTED) {
130567
+ return;
130568
+ }
130569
+ let start = this.pos;
130570
+ const prefix = this.fnString.substr(this.pos, this.fn.name.length);
130571
+ if (prefix === this.fn.name) {
130572
+ this.pos += prefix.length;
130573
+ if (this.consumeSyntax() === "()" && this.consumeSyntax() === "{}" && this.pos === this.fnString.length) {
130574
+ if (this.isMethodCandidate || !quote_1.isValidVariableName(prefix)) {
130575
+ start += prefix.length;
130576
+ }
130577
+ return this.getPrefix() + this.fnString.substr(start);
130578
+ }
130579
+ }
130580
+ this.pos = start;
130581
+ }
130582
+ /**
130583
+ * Attempt to advance the parser past the keywords expected to be at the
130584
+ * start of this function's definition. This method sets `this.hadKeyword`
130585
+ * based on whether or not a `function` keyword is consumed.
130586
+ */
130587
+ tryParsePrefixTokens() {
130588
+ let posPrev = this.pos;
130589
+ this.hadKeyword = false;
130590
+ switch (this.fnType) {
130591
+ case "AsyncFunction":
130592
+ if (this.consumeSyntax() !== "async")
130593
+ return false;
130594
+ posPrev = this.pos;
130595
+ case "Function":
130596
+ if (this.consumeSyntax() === "function") {
130597
+ this.hadKeyword = true;
130598
+ } else {
130599
+ this.pos = posPrev;
130600
+ }
130601
+ return true;
130602
+ case "AsyncGeneratorFunction":
130603
+ if (this.consumeSyntax() !== "async")
130604
+ return false;
130605
+ case "GeneratorFunction":
130606
+ let token = this.consumeSyntax();
130607
+ if (token === "function") {
130608
+ token = this.consumeSyntax();
130609
+ this.hadKeyword = true;
130610
+ }
130611
+ return token === "*";
130612
+ }
130613
+ }
130614
+ /**
130615
+ * Advance the parser past one element of JavaScript syntax. This could be a
130616
+ * matched pair of delimiters, like braces or parentheses, or an atomic unit
130617
+ * like a keyword, variable, or operator. Return a normalized string
130618
+ * representation of the element parsed--for example, returns '{}' for a
130619
+ * matched pair of braces. Comments and whitespace are skipped.
130620
+ *
130621
+ * (This isn't a full parser, so the token scanning logic used here is as
130622
+ * simple as it can be. As a consequence, some things that are one token in
130623
+ * JavaScript, like decimal number literals or most multi-character operators
130624
+ * like '&&', are split into more than one token here. However, awareness of
130625
+ * some multi-character sequences like '=>' is necessary, so we match the few
130626
+ * of them that we care about.)
130627
+ */
130628
+ consumeSyntax(wordLikeToken) {
130629
+ const m = this.consumeMatch(/^(?:([A-Za-z_0-9$\xA0-\uFFFF]+)|=>|\+\+|\-\-|.)/);
130630
+ if (!m)
130631
+ return;
130632
+ const [token, match] = m;
130633
+ this.consumeWhitespace();
130634
+ if (match)
130635
+ return wordLikeToken || match;
130636
+ switch (token) {
130637
+ case "(":
130638
+ return this.consumeSyntaxUntil("(", ")");
130639
+ case "[":
130640
+ return this.consumeSyntaxUntil("[", "]");
130641
+ case "{":
130642
+ return this.consumeSyntaxUntil("{", "}");
130643
+ case "`":
130644
+ return this.consumeTemplate();
130645
+ case '"':
130646
+ return this.consumeRegExp(/^(?:[^\\"]|\\.)*"/, '"');
130647
+ case "'":
130648
+ return this.consumeRegExp(/^(?:[^\\']|\\.)*'/, "'");
130649
+ }
130650
+ return token;
130651
+ }
130652
+ consumeSyntaxUntil(startToken, endToken) {
130653
+ let isRegExpAllowed = true;
130654
+ for (; ; ) {
130655
+ const token = this.consumeSyntax();
130656
+ if (token === endToken)
130657
+ return startToken + endToken;
130658
+ if (!token || token === ")" || token === "]" || token === "}")
130659
+ return;
130660
+ if (token === "/" && isRegExpAllowed && this.consumeMatch(/^(?:\\.|[^\\\/\n[]|\[(?:\\.|[^\]])*\])+\/[a-z]*/)) {
130661
+ isRegExpAllowed = false;
130662
+ this.consumeWhitespace();
130663
+ } else {
130664
+ isRegExpAllowed = TOKENS_PRECEDING_REGEXPS.has(token);
130665
+ }
130666
+ }
130667
+ }
130668
+ consumeMatch(re2) {
130669
+ const m = re2.exec(this.fnString.substr(this.pos));
130670
+ if (m)
130671
+ this.pos += m[0].length;
130672
+ return m;
130673
+ }
130674
+ /**
130675
+ * Advance the parser past an arbitrary regular expression. Return `token`,
130676
+ * or the match object of the regexp.
130677
+ */
130678
+ consumeRegExp(re2, token) {
130679
+ const m = re2.exec(this.fnString.substr(this.pos));
130680
+ if (!m)
130681
+ return;
130682
+ this.pos += m[0].length;
130683
+ this.consumeWhitespace();
130684
+ return token;
130685
+ }
130686
+ /**
130687
+ * Advance the parser past a template string.
130688
+ */
130689
+ consumeTemplate() {
130690
+ for (; ; ) {
130691
+ this.consumeMatch(/^(?:[^`$\\]|\\.|\$(?!{))*/);
130692
+ if (this.fnString[this.pos] === "`") {
130693
+ this.pos++;
130694
+ this.consumeWhitespace();
130695
+ return "`";
130696
+ }
130697
+ if (this.fnString.substr(this.pos, 2) === "${") {
130698
+ this.pos += 2;
130699
+ this.consumeWhitespace();
130700
+ if (this.consumeSyntaxUntil("{", "}"))
130701
+ continue;
130702
+ }
130703
+ return;
130704
+ }
130705
+ }
130706
+ /**
130707
+ * Advance the parser past any whitespace or comments.
130708
+ */
130709
+ consumeWhitespace() {
130710
+ this.consumeMatch(/^(?:\s|\/\/.*|\/\*[^]*?\*\/)*/);
130711
+ }
130712
+ };
130713
+ exports2.FunctionParser = FunctionParser;
130714
+ }
130715
+ });
130716
+
130717
+ // ../../node_modules/javascript-stringify/dist/array.js
130718
+ var require_array2 = __commonJS({
130719
+ "../../node_modules/javascript-stringify/dist/array.js"(exports2) {
130720
+ "use strict";
130721
+ Object.defineProperty(exports2, "__esModule", { value: true });
130722
+ exports2.arrayToString = void 0;
130723
+ var arrayToString = (array, space, next) => {
130724
+ const values = array.map(function(value, index) {
130725
+ const result = next(value, index);
130726
+ if (result === void 0)
130727
+ return String(result);
130728
+ return space + result.split("\n").join(`
130729
+ ${space}`);
130730
+ }).join(space ? ",\n" : ",");
130731
+ const eol = space && values ? "\n" : "";
130732
+ return `[${eol}${values}${eol}]`;
130733
+ };
130734
+ exports2.arrayToString = arrayToString;
130735
+ }
130736
+ });
130737
+
130738
+ // ../../node_modules/javascript-stringify/dist/object.js
130739
+ var require_object2 = __commonJS({
130740
+ "../../node_modules/javascript-stringify/dist/object.js"(exports2) {
130741
+ "use strict";
130742
+ Object.defineProperty(exports2, "__esModule", { value: true });
130743
+ exports2.objectToString = void 0;
130744
+ var quote_1 = require_quote();
130745
+ var function_1 = require_function();
130746
+ var array_1 = require_array2();
130747
+ var objectToString = (value, space, next, key) => {
130748
+ if (typeof Buffer === "function" && Buffer.isBuffer(value)) {
130749
+ return `Buffer.from(${next(value.toString("base64"))}, 'base64')`;
130750
+ }
130751
+ if (typeof global === "object" && value === global) {
130752
+ return globalToString(value, space, next, key);
130753
+ }
130754
+ const toString = OBJECT_TYPES[Object.prototype.toString.call(value)];
130755
+ return toString ? toString(value, space, next, key) : void 0;
130756
+ };
130757
+ exports2.objectToString = objectToString;
130758
+ var rawObjectToString = (obj, indent, next, key) => {
130759
+ const eol = indent ? "\n" : "";
130760
+ const space = indent ? " " : "";
130761
+ const values = Object.keys(obj).reduce(function(values2, key2) {
130762
+ const fn = obj[key2];
130763
+ const result = next(fn, key2);
130764
+ if (result === void 0)
130765
+ return values2;
130766
+ const value = result.split("\n").join(`
130767
+ ${indent}`);
130768
+ if (function_1.USED_METHOD_KEY.has(fn)) {
130769
+ values2.push(`${indent}${value}`);
130770
+ return values2;
130771
+ }
130772
+ values2.push(`${indent}${quote_1.quoteKey(key2, next)}:${space}${value}`);
130773
+ return values2;
130774
+ }, []).join(`,${eol}`);
130775
+ if (values === "")
130776
+ return "{}";
130777
+ return `{${eol}${values}${eol}}`;
130778
+ };
130779
+ var globalToString = (value, space, next) => {
130780
+ return `Function(${next("return this")})()`;
130781
+ };
130782
+ var OBJECT_TYPES = {
130783
+ "[object Array]": array_1.arrayToString,
130784
+ "[object Object]": rawObjectToString,
130785
+ "[object Error]": (error, space, next) => {
130786
+ return `new Error(${next(error.message)})`;
130787
+ },
130788
+ "[object Date]": (date) => {
130789
+ return `new Date(${date.getTime()})`;
130790
+ },
130791
+ "[object String]": (str, space, next) => {
130792
+ return `new String(${next(str.toString())})`;
130793
+ },
130794
+ "[object Number]": (num) => {
130795
+ return `new Number(${num})`;
130796
+ },
130797
+ "[object Boolean]": (bool) => {
130798
+ return `new Boolean(${bool})`;
130799
+ },
130800
+ "[object Set]": (set, space, next) => {
130801
+ return `new Set(${next(Array.from(set))})`;
130802
+ },
130803
+ "[object Map]": (map, space, next) => {
130804
+ return `new Map(${next(Array.from(map))})`;
130805
+ },
130806
+ "[object RegExp]": String,
130807
+ "[object global]": globalToString,
130808
+ "[object Window]": globalToString
130809
+ };
130810
+ }
130811
+ });
130812
+
130813
+ // ../../node_modules/javascript-stringify/dist/stringify.js
130814
+ var require_stringify2 = __commonJS({
130815
+ "../../node_modules/javascript-stringify/dist/stringify.js"(exports2) {
130816
+ "use strict";
130817
+ Object.defineProperty(exports2, "__esModule", { value: true });
130818
+ exports2.toString = void 0;
130819
+ var quote_1 = require_quote();
130820
+ var object_1 = require_object2();
130821
+ var function_1 = require_function();
130822
+ var PRIMITIVE_TYPES = {
130823
+ string: quote_1.quoteString,
130824
+ number: (value) => Object.is(value, -0) ? "-0" : String(value),
130825
+ boolean: String,
130826
+ symbol: (value, space, next) => {
130827
+ const key = Symbol.keyFor(value);
130828
+ if (key !== void 0)
130829
+ return `Symbol.for(${next(key)})`;
130830
+ return `Symbol(${next(value.description)})`;
130831
+ },
130832
+ bigint: (value, space, next) => {
130833
+ return `BigInt(${next(String(value))})`;
130834
+ },
130835
+ undefined: String,
130836
+ object: object_1.objectToString,
130837
+ function: function_1.functionToString
130838
+ };
130839
+ var toString = (value, space, next, key) => {
130840
+ if (value === null)
130841
+ return "null";
130842
+ return PRIMITIVE_TYPES[typeof value](value, space, next, key);
130843
+ };
130844
+ exports2.toString = toString;
130845
+ }
130846
+ });
130847
+
130848
+ // ../../node_modules/javascript-stringify/dist/index.js
130849
+ var require_dist11 = __commonJS({
130850
+ "../../node_modules/javascript-stringify/dist/index.js"(exports2) {
130851
+ "use strict";
130852
+ Object.defineProperty(exports2, "__esModule", { value: true });
130853
+ exports2.stringify = void 0;
130854
+ var stringify_1 = require_stringify2();
130855
+ var quote_1 = require_quote();
130856
+ var ROOT_SENTINEL = Symbol("root");
130857
+ function stringify(value, replacer, indent, options = {}) {
130858
+ const space = typeof indent === "string" ? indent : " ".repeat(indent || 0);
130859
+ const path2 = [];
130860
+ const stack = /* @__PURE__ */ new Set();
130861
+ const tracking = /* @__PURE__ */ new Map();
130862
+ const unpack = /* @__PURE__ */ new Map();
130863
+ let valueCount = 0;
130864
+ const { maxDepth = 100, references = false, skipUndefinedProperties = false, maxValues = 1e5 } = options;
130865
+ const valueToString = replacerToString(replacer);
130866
+ const onNext = (value2, key) => {
130867
+ if (++valueCount > maxValues)
130868
+ return;
130869
+ if (skipUndefinedProperties && value2 === void 0)
130870
+ return;
130871
+ if (path2.length > maxDepth)
130872
+ return;
130873
+ if (key === void 0)
130874
+ return valueToString(value2, space, onNext, key);
130875
+ path2.push(key);
130876
+ const result2 = builder(value2, key === ROOT_SENTINEL ? void 0 : key);
130877
+ path2.pop();
130878
+ return result2;
130879
+ };
130880
+ const builder = references ? (value2, key) => {
130881
+ if (value2 !== null && (typeof value2 === "object" || typeof value2 === "function" || typeof value2 === "symbol")) {
130882
+ if (tracking.has(value2)) {
130883
+ unpack.set(path2.slice(1), tracking.get(value2));
130884
+ return valueToString(void 0, space, onNext, key);
130885
+ }
130886
+ tracking.set(value2, path2.slice(1));
130887
+ }
130888
+ return valueToString(value2, space, onNext, key);
130889
+ } : (value2, key) => {
130890
+ if (stack.has(value2))
130891
+ return;
130892
+ stack.add(value2);
130893
+ const result2 = valueToString(value2, space, onNext, key);
130894
+ stack.delete(value2);
130895
+ return result2;
130896
+ };
130897
+ const result = onNext(value, ROOT_SENTINEL);
130898
+ if (unpack.size) {
130899
+ const sp = space ? " " : "";
130900
+ const eol = space ? "\n" : "";
130901
+ let wrapper = `var x${sp}=${sp}${result};${eol}`;
130902
+ for (const [key, value2] of unpack.entries()) {
130903
+ const keyPath = quote_1.stringifyPath(key, onNext);
130904
+ const valuePath = quote_1.stringifyPath(value2, onNext);
130905
+ wrapper += `x${keyPath}${sp}=${sp}x${valuePath};${eol}`;
130906
+ }
130907
+ return `(function${sp}()${sp}{${eol}${wrapper}return x;${eol}}())`;
130908
+ }
130909
+ return result;
130910
+ }
130911
+ exports2.stringify = stringify;
130912
+ function replacerToString(replacer) {
130913
+ if (!replacer)
130914
+ return stringify_1.toString;
130915
+ return (value, space, next, key) => {
130916
+ return replacer(value, space, (value2) => stringify_1.toString(value2, space, next, key), key);
130917
+ };
130918
+ }
130919
+ }
130920
+ });
130921
+
130378
130922
  // dist/cms/index.js
130379
130923
  var require_cms = __commonJS({
130380
130924
  "dist/cms/index.js"(exports2) {
@@ -130386,6 +130930,7 @@ var require_cms = __commonJS({
130386
130930
  exports2.getDataExtensionAndCollectionsFiles = void 0;
130387
130931
  var path_1 = __importDefault2(require("path"));
130388
130932
  var crypto_1 = require("crypto");
130933
+ var javascript_stringify_1 = require_dist11();
130389
130934
  var getDataExtensionAndCollectionsFiles = ({ plan, appNamespace }) => {
130390
130935
  if (!plan.collections?.length) {
130391
130936
  return [];
@@ -130401,10 +130946,16 @@ export const dataExtension = genericExtension({
130401
130946
  compType: 'DATA_COMPONENT',
130402
130947
  compData: {
130403
130948
  dataComponent: {
130404
- collections: [${plan.collections.map((collection) => `{
130949
+ collections: [${plan.collections.map((collection) => {
130950
+ const { id: _id, initialData: _initialData, ...rest } = collection;
130951
+ const formattedRest = (0, javascript_stringify_1.stringify)(rest, null, 2) ?? "";
130952
+ const formattedProps = formattedRest.replace(/^\s*{\s*\n?/, "").replace(/\n?\s*}\s*$/, "");
130953
+ return `{
130405
130954
  id: '${path_1.default.join(appNamespace, collection.id ?? "no-collection-id")}',
130406
130955
  schemaUrl: '{{BASE_URL}}/collections/${collection.id}/schema.json',
130407
- }`).join(",\n")}]
130956
+ ${formattedProps}
130957
+ }`;
130958
+ }).join(",\n")}]
130408
130959
  }
130409
130960
  }
130410
130961
  })
@@ -130414,11 +130965,12 @@ export const dataExtension = genericExtension({
130414
130965
  if (!collection.id) {
130415
130966
  return;
130416
130967
  }
130968
+ const { initialData: _initialData, ...collectionWithoutInitialData } = collection;
130417
130969
  const collectionDirPath = path_1.default.join("public", "collections", collection.id);
130418
130970
  files.push({
130419
130971
  operation: "insert",
130420
130972
  path: path_1.default.join(collectionDirPath, "schema.json"),
130421
- content: JSON.stringify(collection, null, 2)
130973
+ content: JSON.stringify(collectionWithoutInitialData, null, 2)
130422
130974
  });
130423
130975
  });
130424
130976
  return files;
@@ -134514,7 +135066,7 @@ var require_helpers = __commonJS({
134514
135066
  });
134515
135067
 
134516
135068
  // ../../node_modules/agent-base/dist/index.js
134517
- var require_dist11 = __commonJS({
135069
+ var require_dist12 = __commonJS({
134518
135070
  "../../node_modules/agent-base/dist/index.js"(exports2) {
134519
135071
  "use strict";
134520
135072
  var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
@@ -134670,7 +135222,7 @@ var require_dist11 = __commonJS({
134670
135222
  });
134671
135223
 
134672
135224
  // ../../node_modules/http-proxy-agent/dist/index.js
134673
- var require_dist12 = __commonJS({
135225
+ var require_dist13 = __commonJS({
134674
135226
  "../../node_modules/http-proxy-agent/dist/index.js"(exports2) {
134675
135227
  "use strict";
134676
135228
  var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
@@ -134709,7 +135261,7 @@ var require_dist12 = __commonJS({
134709
135261
  var tls = __importStar2(require("tls"));
134710
135262
  var debug_1 = __importDefault2(require_src9());
134711
135263
  var events_1 = require("events");
134712
- var agent_base_1 = require_dist11();
135264
+ var agent_base_1 = require_dist12();
134713
135265
  var url_1 = require("url");
134714
135266
  var debug = (0, debug_1.default)("http-proxy-agent");
134715
135267
  var HttpProxyAgent = class extends agent_base_1.Agent {
@@ -134896,7 +135448,7 @@ var require_parse_proxy_response = __commonJS({
134896
135448
  });
134897
135449
 
134898
135450
  // ../../node_modules/@wix/http-client/node_modules/https-proxy-agent/dist/index.js
134899
- var require_dist13 = __commonJS({
135451
+ var require_dist14 = __commonJS({
134900
135452
  "../../node_modules/@wix/http-client/node_modules/https-proxy-agent/dist/index.js"(exports2) {
134901
135453
  "use strict";
134902
135454
  var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
@@ -134935,7 +135487,7 @@ var require_dist13 = __commonJS({
134935
135487
  var tls = __importStar2(require("tls"));
134936
135488
  var assert_1 = __importDefault2(require("assert"));
134937
135489
  var debug_1 = __importDefault2(require_src9());
134938
- var agent_base_1 = require_dist11();
135490
+ var agent_base_1 = require_dist12();
134939
135491
  var url_1 = require("url");
134940
135492
  var parse_proxy_response_1 = require_parse_proxy_response();
134941
135493
  var debug = (0, debug_1.default)("https-proxy-agent");
@@ -136307,8 +136859,8 @@ var require_http_client_node = __commonJS({
136307
136859
  exports2.HttpClient = exports2.createHttpClient = void 0;
136308
136860
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
136309
136861
  var http_1 = tslib_1.__importDefault(require_http());
136310
- var http_proxy_agent_1 = require_dist12();
136311
- var https_proxy_agent_1 = require_dist13();
136862
+ var http_proxy_agent_1 = require_dist13();
136863
+ var https_proxy_agent_1 = require_dist14();
136312
136864
  var env_util_1 = require_env_util();
136313
136865
  var http_client_1 = require_http_client();
136314
136866
  var MAX_NUMBER_OF_REPORTING_PROXY_METRICS_ATTEMPTS = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.25.9"
26
26
  },
27
- "falconPackageHash": "2aebcac759bbd4ac3c62996647812ea539fd3a3a3afd3ea322df2c92"
27
+ "falconPackageHash": "ac7425a373a17a9b351d3857f423f71a64f43962465650a36cd25e9e"
28
28
  }