@builder.io/sdk-svelte 0.1.16 → 0.2.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "0.1.15",
4
+ "version": "0.1.16",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "package",
@@ -1,3 +1,21 @@
1
+ ### 0.2.0
2
+ - Sets the default `apiVersion` to `v3`.
3
+
4
+ In case you feel the need to use our older API Version `v2`, reach out to us at support@builder.io first. But you can override the default by setting `apiVersion` explicitly to `v2` as follows:
5
+
6
+ ```jsx
7
+ <RenderContent apiVersion="v2" />
8
+ ```
9
+
10
+ ```js
11
+ getContent({ apiVersion: "v2" })
12
+ ```
13
+ More details on the Builder API Versions visit [this link](https://www.builder.io/c/docs/content-api-versions).
14
+
15
+ ### 0.1.16
16
+
17
+ - No changes.
18
+
1
19
  ### 0.1.15
2
20
 
3
21
  - No changes.
@@ -1,7 +1,8 @@
1
1
  import { flatten } from '../../helpers/flatten.js';
2
2
  import { getBuilderSearchParamsFromWindow, normalizeSearchParams, } from '../get-builder-search-params/index.js';
3
+ import { DEFAULT_API_VERSION } from '../../types/api-version';
3
4
  export const generateContentUrl = (options) => {
4
- const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = 'v2', } = options;
5
+ const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = DEFAULT_API_VERSION, } = options;
5
6
  if (!apiKey) {
6
7
  throw new Error('Missing API key');
7
8
  }
@@ -28,6 +28,15 @@ describe('Generate Content URL', () => {
28
28
  });
29
29
  expect(output).toMatchSnapshot();
30
30
  });
31
+ test('generate content url with apiVersion as default', () => {
32
+ const output = generateContentUrl({
33
+ apiKey: testKey,
34
+ model: testModel,
35
+ query: { id: testId },
36
+ options,
37
+ });
38
+ expect(output).toMatchSnapshot();
39
+ });
31
40
  test('generate content url with apiVersion as v2', () => {
32
41
  const output = generateContentUrl({
33
42
  apiKey: testKey,
@@ -39,7 +39,7 @@ export interface GetContentOptions {
39
39
  /**
40
40
  * If provided, sets the Builder API version used to fetch content.
41
41
  *
42
- * Defaults to `v2`.
42
+ * Defaults to `v3`.
43
43
  */
44
44
  apiVersion?: 'v2' | 'v3';
45
45
  }
@@ -1 +1,2 @@
1
1
  export type ApiVersion = 'v2' | 'v3';
2
+ export declare const DEFAULT_API_VERSION: ApiVersion;
@@ -1 +1 @@
1
- export {};
1
+ export const DEFAULT_API_VERSION = 'v3';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "0.1.16",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "package",
@@ -35,6 +35,16 @@ describe('Generate Content URL', () => {
35
35
  expect(output).toMatchSnapshot();
36
36
  });
37
37
 
38
+ test('generate content url with apiVersion as default', () => {
39
+ const output = generateContentUrl({
40
+ apiKey: testKey,
41
+ model: testModel,
42
+ query: { id: testId },
43
+ options,
44
+ });
45
+ expect(output).toMatchSnapshot();
46
+ });
47
+
38
48
  test('generate content url with apiVersion as v2', () => {
39
49
  const output = generateContentUrl({
40
50
  apiKey: testKey,
@@ -4,6 +4,7 @@ import {
4
4
  normalizeSearchParams,
5
5
  } from '../get-builder-search-params/index.js';
6
6
  import type { GetContentOptions } from './types.js';
7
+ import { DEFAULT_API_VERSION } from '../../types/api-version';
7
8
 
8
9
  export const generateContentUrl = (options: GetContentOptions): URL => {
9
10
  const {
@@ -15,7 +16,7 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
15
16
  apiKey,
16
17
  includeRefs = true,
17
18
  locale,
18
- apiVersion = 'v2',
19
+ apiVersion = DEFAULT_API_VERSION,
19
20
  } = options;
20
21
 
21
22
  if (!apiKey) {
@@ -47,7 +47,7 @@ export interface GetContentOptions {
47
47
  /**
48
48
  * If provided, sets the Builder API version used to fetch content.
49
49
  *
50
- * Defaults to `v2`.
50
+ * Defaults to `v3`.
51
51
  */
52
52
  apiVersion?: 'v2' | 'v3';
53
53
  }
@@ -1 +1,2 @@
1
1
  export type ApiVersion = 'v2' | 'v3';
2
+ export const DEFAULT_API_VERSION: ApiVersion = 'v3';