@builder.io/sdk-qwik 0.16.23 → 0.17.0

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 (27) hide show
  1. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  2. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  3. package/lib/browser/functions/get-content/generate-content-url.qwik.cjs +11 -4
  4. package/lib/browser/functions/get-content/generate-content-url.qwik.mjs +11 -4
  5. package/lib/browser/functions/get-content/index.qwik.cjs +10 -15
  6. package/lib/browser/functions/get-content/index.qwik.mjs +10 -15
  7. package/lib/browser/functions/register-component.qwik.cjs +2 -1
  8. package/lib/browser/functions/register-component.qwik.mjs +2 -1
  9. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  10. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  11. package/lib/edge/functions/get-content/generate-content-url.qwik.cjs +11 -4
  12. package/lib/edge/functions/get-content/generate-content-url.qwik.mjs +11 -4
  13. package/lib/edge/functions/get-content/index.qwik.cjs +10 -15
  14. package/lib/edge/functions/get-content/index.qwik.mjs +10 -15
  15. package/lib/edge/functions/register-component.qwik.cjs +2 -1
  16. package/lib/edge/functions/register-component.qwik.mjs +2 -1
  17. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  18. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  19. package/lib/node/functions/get-content/generate-content-url.qwik.cjs +11 -4
  20. package/lib/node/functions/get-content/generate-content-url.qwik.mjs +11 -4
  21. package/lib/node/functions/get-content/index.qwik.cjs +10 -15
  22. package/lib/node/functions/get-content/index.qwik.mjs +10 -15
  23. package/lib/node/functions/register-component.qwik.cjs +2 -1
  24. package/lib/node/functions/register-component.qwik.mjs +2 -1
  25. package/package.json +1 -1
  26. package/types/src/constants/sdk-version.d.ts +1 -1
  27. package/types/src/functions/get-content/index.d.ts +1 -1
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.23";
3
+ const SDK_VERSION = "0.17.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.23";
1
+ const SDK_VERSION = "0.17.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -20,8 +20,15 @@ const generateContentUrl = (options) => {
20
20
  url.searchParams.set("limit", String(limit));
21
21
  url.searchParams.set("noTraverse", String(noTraverse));
22
22
  url.searchParams.set("includeRefs", String(true));
23
- if (locale)
24
- url.searchParams.set("locale", locale);
23
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
24
+ let finalUserAttributes = userAttributes;
25
+ if (finalLocale) {
26
+ url.searchParams.set("locale", finalLocale);
27
+ finalUserAttributes = {
28
+ locale: finalLocale,
29
+ ...finalUserAttributes
30
+ };
31
+ }
25
32
  if (enrich)
26
33
  url.searchParams.set("enrich", String(enrich));
27
34
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -49,8 +56,8 @@ const generateContentUrl = (options) => {
49
56
  const flattened = flatten.flatten(queryOptions);
50
57
  for (const key in flattened)
51
58
  url.searchParams.set(key, String(flattened[key]));
52
- if (userAttributes)
53
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
59
+ if (finalUserAttributes)
60
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
54
61
  if (query) {
55
62
  const flattened2 = flatten.flattenMongoQuery({
56
63
  query
@@ -18,8 +18,15 @@ const generateContentUrl = (options) => {
18
18
  url.searchParams.set("limit", String(limit));
19
19
  url.searchParams.set("noTraverse", String(noTraverse));
20
20
  url.searchParams.set("includeRefs", String(true));
21
- if (locale)
22
- url.searchParams.set("locale", locale);
21
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
22
+ let finalUserAttributes = userAttributes;
23
+ if (finalLocale) {
24
+ url.searchParams.set("locale", finalLocale);
25
+ finalUserAttributes = {
26
+ locale: finalLocale,
27
+ ...finalUserAttributes
28
+ };
29
+ }
23
30
  if (enrich)
24
31
  url.searchParams.set("enrich", String(enrich));
25
32
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -47,8 +54,8 @@ const generateContentUrl = (options) => {
47
54
  const flattened = flatten(queryOptions);
48
55
  for (const key in flattened)
49
56
  url.searchParams.set(key, String(flattened[key]));
50
- if (userAttributes)
51
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
57
+ if (finalUserAttributes)
58
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
52
59
  if (query) {
53
60
  const flattened2 = flattenMongoQuery({
54
61
  query
@@ -54,22 +54,17 @@ const _processContentResult = async (options, content, url = generateContentUrl.
54
54
  return content.results;
55
55
  };
56
56
  async function fetchEntries(options) {
57
- try {
58
- const url = generateContentUrl.generateContentUrl(options);
59
- const content = await _fetchContent(options);
60
- if (!checkContentHasResults(content)) {
61
- logger.logger.error("Error fetching data. ", {
62
- url,
63
- content,
64
- options
65
- });
66
- return null;
67
- }
68
- return _processContentResult(options, content);
69
- } catch (error) {
70
- logger.logger.error("Error fetching data. ", error);
71
- return null;
57
+ const url = generateContentUrl.generateContentUrl(options);
58
+ const content = await _fetchContent(options);
59
+ if (!checkContentHasResults(content)) {
60
+ logger.logger.error("Error fetching data. ", {
61
+ url,
62
+ content,
63
+ options
64
+ });
65
+ throw content;
72
66
  }
67
+ return _processContentResult(options, content);
73
68
  }
74
69
  exports._processContentResult = _processContentResult;
75
70
  exports.fetchEntries = fetchEntries;
@@ -52,22 +52,17 @@ const _processContentResult = async (options, content, url = generateContentUrl(
52
52
  return content.results;
53
53
  };
54
54
  async function fetchEntries(options) {
55
- try {
56
- const url = generateContentUrl(options);
57
- const content = await _fetchContent(options);
58
- if (!checkContentHasResults(content)) {
59
- logger.error("Error fetching data. ", {
60
- url,
61
- content,
62
- options
63
- });
64
- return null;
65
- }
66
- return _processContentResult(options, content);
67
- } catch (error) {
68
- logger.error("Error fetching data. ", error);
69
- return null;
55
+ const url = generateContentUrl(options);
56
+ const content = await _fetchContent(options);
57
+ if (!checkContentHasResults(content)) {
58
+ logger.error("Error fetching data. ", {
59
+ url,
60
+ content,
61
+ options
62
+ });
63
+ throw content;
70
64
  }
65
+ return _processContentResult(options, content);
71
66
  }
72
67
  export {
73
68
  _processContentResult,
@@ -6,7 +6,8 @@ const createRegisterComponentMessage = (info) => ({
6
6
  });
7
7
  const serializeFn = (fnValue) => {
8
8
  const fnStr = fnValue.toString().trim();
9
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
9
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
10
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
10
11
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
11
12
  };
12
13
  function serializeIncludingFunctions(info) {
@@ -4,7 +4,8 @@ const createRegisterComponentMessage = (info) => ({
4
4
  });
5
5
  const serializeFn = (fnValue) => {
6
6
  const fnStr = fnValue.toString().trim();
7
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
7
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
8
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
8
9
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
9
10
  };
10
11
  function serializeIncludingFunctions(info) {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.23";
3
+ const SDK_VERSION = "0.17.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.23";
1
+ const SDK_VERSION = "0.17.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -20,8 +20,15 @@ const generateContentUrl = (options) => {
20
20
  url.searchParams.set("limit", String(limit));
21
21
  url.searchParams.set("noTraverse", String(noTraverse));
22
22
  url.searchParams.set("includeRefs", String(true));
23
- if (locale)
24
- url.searchParams.set("locale", locale);
23
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
24
+ let finalUserAttributes = userAttributes;
25
+ if (finalLocale) {
26
+ url.searchParams.set("locale", finalLocale);
27
+ finalUserAttributes = {
28
+ locale: finalLocale,
29
+ ...finalUserAttributes
30
+ };
31
+ }
25
32
  if (enrich)
26
33
  url.searchParams.set("enrich", String(enrich));
27
34
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -49,8 +56,8 @@ const generateContentUrl = (options) => {
49
56
  const flattened = flatten.flatten(queryOptions);
50
57
  for (const key in flattened)
51
58
  url.searchParams.set(key, String(flattened[key]));
52
- if (userAttributes)
53
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
59
+ if (finalUserAttributes)
60
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
54
61
  if (query) {
55
62
  const flattened2 = flatten.flattenMongoQuery({
56
63
  query
@@ -18,8 +18,15 @@ const generateContentUrl = (options) => {
18
18
  url.searchParams.set("limit", String(limit));
19
19
  url.searchParams.set("noTraverse", String(noTraverse));
20
20
  url.searchParams.set("includeRefs", String(true));
21
- if (locale)
22
- url.searchParams.set("locale", locale);
21
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
22
+ let finalUserAttributes = userAttributes;
23
+ if (finalLocale) {
24
+ url.searchParams.set("locale", finalLocale);
25
+ finalUserAttributes = {
26
+ locale: finalLocale,
27
+ ...finalUserAttributes
28
+ };
29
+ }
23
30
  if (enrich)
24
31
  url.searchParams.set("enrich", String(enrich));
25
32
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -47,8 +54,8 @@ const generateContentUrl = (options) => {
47
54
  const flattened = flatten(queryOptions);
48
55
  for (const key in flattened)
49
56
  url.searchParams.set(key, String(flattened[key]));
50
- if (userAttributes)
51
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
57
+ if (finalUserAttributes)
58
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
52
59
  if (query) {
53
60
  const flattened2 = flattenMongoQuery({
54
61
  query
@@ -54,22 +54,17 @@ const _processContentResult = async (options, content, url = generateContentUrl.
54
54
  return content.results;
55
55
  };
56
56
  async function fetchEntries(options) {
57
- try {
58
- const url = generateContentUrl.generateContentUrl(options);
59
- const content = await _fetchContent(options);
60
- if (!checkContentHasResults(content)) {
61
- logger.logger.error("Error fetching data. ", {
62
- url,
63
- content,
64
- options
65
- });
66
- return null;
67
- }
68
- return _processContentResult(options, content);
69
- } catch (error) {
70
- logger.logger.error("Error fetching data. ", error);
71
- return null;
57
+ const url = generateContentUrl.generateContentUrl(options);
58
+ const content = await _fetchContent(options);
59
+ if (!checkContentHasResults(content)) {
60
+ logger.logger.error("Error fetching data. ", {
61
+ url,
62
+ content,
63
+ options
64
+ });
65
+ throw content;
72
66
  }
67
+ return _processContentResult(options, content);
73
68
  }
74
69
  exports._processContentResult = _processContentResult;
75
70
  exports.fetchEntries = fetchEntries;
@@ -52,22 +52,17 @@ const _processContentResult = async (options, content, url = generateContentUrl(
52
52
  return content.results;
53
53
  };
54
54
  async function fetchEntries(options) {
55
- try {
56
- const url = generateContentUrl(options);
57
- const content = await _fetchContent(options);
58
- if (!checkContentHasResults(content)) {
59
- logger.error("Error fetching data. ", {
60
- url,
61
- content,
62
- options
63
- });
64
- return null;
65
- }
66
- return _processContentResult(options, content);
67
- } catch (error) {
68
- logger.error("Error fetching data. ", error);
69
- return null;
55
+ const url = generateContentUrl(options);
56
+ const content = await _fetchContent(options);
57
+ if (!checkContentHasResults(content)) {
58
+ logger.error("Error fetching data. ", {
59
+ url,
60
+ content,
61
+ options
62
+ });
63
+ throw content;
70
64
  }
65
+ return _processContentResult(options, content);
71
66
  }
72
67
  export {
73
68
  _processContentResult,
@@ -6,7 +6,8 @@ const createRegisterComponentMessage = (info) => ({
6
6
  });
7
7
  const serializeFn = (fnValue) => {
8
8
  const fnStr = fnValue.toString().trim();
9
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
9
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
10
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
10
11
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
11
12
  };
12
13
  function serializeIncludingFunctions(info) {
@@ -4,7 +4,8 @@ const createRegisterComponentMessage = (info) => ({
4
4
  });
5
5
  const serializeFn = (fnValue) => {
6
6
  const fnStr = fnValue.toString().trim();
7
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
7
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
8
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
8
9
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
9
10
  };
10
11
  function serializeIncludingFunctions(info) {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.23";
3
+ const SDK_VERSION = "0.17.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.23";
1
+ const SDK_VERSION = "0.17.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -20,8 +20,15 @@ const generateContentUrl = (options) => {
20
20
  url.searchParams.set("limit", String(limit));
21
21
  url.searchParams.set("noTraverse", String(noTraverse));
22
22
  url.searchParams.set("includeRefs", String(true));
23
- if (locale)
24
- url.searchParams.set("locale", locale);
23
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
24
+ let finalUserAttributes = userAttributes;
25
+ if (finalLocale) {
26
+ url.searchParams.set("locale", finalLocale);
27
+ finalUserAttributes = {
28
+ locale: finalLocale,
29
+ ...finalUserAttributes
30
+ };
31
+ }
25
32
  if (enrich)
26
33
  url.searchParams.set("enrich", String(enrich));
27
34
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -49,8 +56,8 @@ const generateContentUrl = (options) => {
49
56
  const flattened = flatten.flatten(queryOptions);
50
57
  for (const key in flattened)
51
58
  url.searchParams.set(key, String(flattened[key]));
52
- if (userAttributes)
53
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
59
+ if (finalUserAttributes)
60
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
54
61
  if (query) {
55
62
  const flattened2 = flatten.flattenMongoQuery({
56
63
  query
@@ -18,8 +18,15 @@ const generateContentUrl = (options) => {
18
18
  url.searchParams.set("limit", String(limit));
19
19
  url.searchParams.set("noTraverse", String(noTraverse));
20
20
  url.searchParams.set("includeRefs", String(true));
21
- if (locale)
22
- url.searchParams.set("locale", locale);
21
+ const finalLocale = locale || (userAttributes == null ? void 0 : userAttributes.locale);
22
+ let finalUserAttributes = userAttributes;
23
+ if (finalLocale) {
24
+ url.searchParams.set("locale", finalLocale);
25
+ finalUserAttributes = {
26
+ locale: finalLocale,
27
+ ...finalUserAttributes
28
+ };
29
+ }
23
30
  if (enrich)
24
31
  url.searchParams.set("enrich", String(enrich));
25
32
  url.searchParams.set("omit", omit || "meta.componentsUsed");
@@ -47,8 +54,8 @@ const generateContentUrl = (options) => {
47
54
  const flattened = flatten(queryOptions);
48
55
  for (const key in flattened)
49
56
  url.searchParams.set(key, String(flattened[key]));
50
- if (userAttributes)
51
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
57
+ if (finalUserAttributes)
58
+ url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
52
59
  if (query) {
53
60
  const flattened2 = flattenMongoQuery({
54
61
  query
@@ -54,22 +54,17 @@ const _processContentResult = async (options, content, url = generateContentUrl.
54
54
  return content.results;
55
55
  };
56
56
  async function fetchEntries(options) {
57
- try {
58
- const url = generateContentUrl.generateContentUrl(options);
59
- const content = await _fetchContent(options);
60
- if (!checkContentHasResults(content)) {
61
- logger.logger.error("Error fetching data. ", {
62
- url,
63
- content,
64
- options
65
- });
66
- return null;
67
- }
68
- return _processContentResult(options, content);
69
- } catch (error) {
70
- logger.logger.error("Error fetching data. ", error);
71
- return null;
57
+ const url = generateContentUrl.generateContentUrl(options);
58
+ const content = await _fetchContent(options);
59
+ if (!checkContentHasResults(content)) {
60
+ logger.logger.error("Error fetching data. ", {
61
+ url,
62
+ content,
63
+ options
64
+ });
65
+ throw content;
72
66
  }
67
+ return _processContentResult(options, content);
73
68
  }
74
69
  exports._processContentResult = _processContentResult;
75
70
  exports.fetchEntries = fetchEntries;
@@ -52,22 +52,17 @@ const _processContentResult = async (options, content, url = generateContentUrl(
52
52
  return content.results;
53
53
  };
54
54
  async function fetchEntries(options) {
55
- try {
56
- const url = generateContentUrl(options);
57
- const content = await _fetchContent(options);
58
- if (!checkContentHasResults(content)) {
59
- logger.error("Error fetching data. ", {
60
- url,
61
- content,
62
- options
63
- });
64
- return null;
65
- }
66
- return _processContentResult(options, content);
67
- } catch (error) {
68
- logger.error("Error fetching data. ", error);
69
- return null;
55
+ const url = generateContentUrl(options);
56
+ const content = await _fetchContent(options);
57
+ if (!checkContentHasResults(content)) {
58
+ logger.error("Error fetching data. ", {
59
+ url,
60
+ content,
61
+ options
62
+ });
63
+ throw content;
70
64
  }
65
+ return _processContentResult(options, content);
71
66
  }
72
67
  export {
73
68
  _processContentResult,
@@ -6,7 +6,8 @@ const createRegisterComponentMessage = (info) => ({
6
6
  });
7
7
  const serializeFn = (fnValue) => {
8
8
  const fnStr = fnValue.toString().trim();
9
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
9
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
10
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
10
11
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
11
12
  };
12
13
  function serializeIncludingFunctions(info) {
@@ -4,7 +4,8 @@ const createRegisterComponentMessage = (info) => ({
4
4
  });
5
5
  const serializeFn = (fnValue) => {
6
6
  const fnStr = fnValue.toString().trim();
7
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
7
+ const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
8
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
8
9
  return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
9
10
  };
10
11
  function serializeIncludingFunctions(info) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.16.23",
3
+ "version": "0.17.0",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.16.23";
1
+ export declare const SDK_VERSION = "0.17.0";
@@ -14,5 +14,5 @@ export declare const _processContentResult: (options: GetContentOptions, content
14
14
  /**
15
15
  * Returns a paginated array of entries that match the given options.
16
16
  */
17
- export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[] | null>;
17
+ export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
18
18
  export {};