@builder.io/sdk 1.1.26 → 1.1.27-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.
Files changed (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +5 -4
  3. package/dist/index.browser.js +1 -1
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.cjs.js +63 -56
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.esm.js +63 -56
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +7 -6
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.umd.js +63 -56
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/package.json +9 -2
  14. package/dist/src/builder.class.d.ts +203 -18
  15. package/dist/src/builder.class.js +65 -57
  16. package/dist/src/builder.class.js.map +1 -1
  17. package/dist/src/classes/animator.class.js +13 -12
  18. package/dist/src/classes/animator.class.js.map +1 -1
  19. package/dist/src/classes/cookies.class.js +8 -8
  20. package/dist/src/classes/cookies.class.js.map +1 -1
  21. package/dist/src/classes/observable.class.js +2 -1
  22. package/dist/src/classes/observable.class.js.map +1 -1
  23. package/dist/src/classes/promise.class.js +5 -4
  24. package/dist/src/classes/promise.class.js.map +1 -1
  25. package/dist/src/classes/query-string.class.js +2 -1
  26. package/dist/src/classes/query-string.class.js.map +1 -1
  27. package/dist/src/constants/builder.js +1 -0
  28. package/dist/src/constants/builder.js.map +1 -1
  29. package/dist/src/functions/assign.function.js +1 -0
  30. package/dist/src/functions/assign.function.js.map +1 -1
  31. package/dist/src/functions/fetch.function.js +3 -2
  32. package/dist/src/functions/fetch.function.js.map +1 -1
  33. package/dist/src/functions/finder.function.js +13 -11
  34. package/dist/src/functions/finder.function.js.map +1 -1
  35. package/dist/src/functions/get-top-level-domain.js +1 -0
  36. package/dist/src/functions/get-top-level-domain.js.map +1 -1
  37. package/dist/src/functions/next-tick.function.js +1 -0
  38. package/dist/src/functions/next-tick.function.js.map +1 -1
  39. package/dist/src/functions/omit.function.js +1 -0
  40. package/dist/src/functions/omit.function.js.map +1 -1
  41. package/dist/src/functions/throttle.function.js +1 -0
  42. package/dist/src/functions/throttle.function.js.map +1 -1
  43. package/dist/src/functions/uuid.js +1 -0
  44. package/dist/src/functions/uuid.js.map +1 -1
  45. package/dist/src/types/element.d.ts +4 -2
  46. package/docs/interfaces/Component.md +267 -0
  47. package/docs/interfaces/GetContentOptions.md +396 -0
  48. package/docs/interfaces/Input.md +232 -0
  49. package/docs/interfaces/InsertMenuConfig.md +83 -0
  50. package/docs/interfaces/InsertMenuItem.md +39 -0
  51. package/docs/interfaces/ParamsMap.md +5 -0
  52. package/docs/interfaces/UserAttributes.md +25 -0
  53. package/jest.config.ts +4 -4
  54. package/package.json +9 -2
  55. package/scripts/cleanup-generated-docs.js +18 -0
  56. package/typedoc.js +5 -0
  57. package/BUILD +0 -19
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk",
3
- "version": "1.1.25",
3
+ "version": "1.1.27-1",
4
4
  "unpkg": "./dist/index.browser.js",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -13,6 +13,9 @@
13
13
  "scripts": {
14
14
  "_unlink": "npm unlink *",
15
15
  "_install": "npm install",
16
+ "docs": "npm run docs:generate && npm run docs:cleanup",
17
+ "docs:generate": "typedoc",
18
+ "docs:cleanup": "node scripts/cleanup-generated-docs",
16
19
  "build": "npm run tsc && rollup -c",
17
20
  "watch": "rollup -cw",
18
21
  "start": "npm run watch",
@@ -41,6 +44,8 @@
41
44
  "@types/virtual-dom": "^2.0.27",
42
45
  "esbuild": "0.14.14",
43
46
  "esbuild-runner": "2.2.1",
47
+ "glob": "^7.2.3",
48
+ "glob-promise": "^4.2.2",
44
49
  "jest": "27.4.7",
45
50
  "rollup": "^0.58.2",
46
51
  "rollup-plugin-alias": "^1.4.0",
@@ -53,7 +58,9 @@
53
58
  "rollup-plugin-typescript": "^0.8.1",
54
59
  "rollup-plugin-typescript2": "^0.13.0",
55
60
  "rollup-plugin-uglify": "^3.0.0",
56
- "typescript": "^3.8.3"
61
+ "typedoc": "^0.22.15",
62
+ "typedoc-plugin-markdown": "^3.12.1",
63
+ "typescript": "^4.6.4"
57
64
  },
58
65
  "dependencies": {
59
66
  "hash-sum": "^2.0.0",
@@ -48,30 +48,75 @@ export interface UserAttributes {
48
48
  * URL path of the current user.
49
49
  */
50
50
  urlPath?: string;
51
- /** @deprecated */
51
+ /**
52
+ * @deprecated
53
+ * @hidden
54
+ */
52
55
  queryString?: string | ParamsMap;
53
- /** @deprecated */
56
+ /**
57
+ * @deprecated
58
+ * @hidden
59
+ */
54
60
  device?: 'mobile' | 'tablet' | 'desktop';
55
- /** @deprecated */
61
+ /**
62
+ * @deprecated
63
+ * @hidden
64
+ */
56
65
  location?: any;
57
- /** @deprecated */
66
+ /**
67
+ * @deprecated
68
+ * @hidden
69
+ */
58
70
  userAgent?: string;
59
- /** @deprecated */
71
+ /**
72
+ * @deprecated
73
+ * @hidden
74
+ */
60
75
  referrer?: string;
61
- /** @deprecated */
76
+ /**
77
+ * @deprecated
78
+ * @hidden
79
+ */
62
80
  entryMedium?: string;
63
- /** @deprecated */
81
+ /**
82
+ * @deprecated
83
+ * @hidden
84
+ */
64
85
  language?: string;
65
- /** @deprecated */
86
+ /**
87
+ * @deprecated
88
+ * @hidden
89
+ */
66
90
  browser?: string;
67
- /** @deprecated */
91
+ /**
92
+ * @deprecated
93
+ * @hidden
94
+ */
68
95
  cookie?: string;
69
- /** @deprecated */
96
+ /**
97
+ * @deprecated
98
+ * @hidden
99
+ */
70
100
  newVisitor?: boolean;
71
- /** @deprecated */
101
+ /**
102
+ * @deprecated
103
+ * @hidden
104
+ */
72
105
  operatingSystem?: string;
73
106
  }
74
107
  export interface GetContentOptions {
108
+ /**
109
+ * User attribute key value pairs to be used for targeting
110
+ * https://www.builder.io/c/docs/custom-targeting-attributes
111
+ *
112
+ * e.g.
113
+ * ```js
114
+ * userAttributes: {
115
+ * urlPath: '/',
116
+ * returnVisitor: true,
117
+ * }
118
+ * ```
119
+ */
75
120
  userAttributes?: UserAttributes;
76
121
  /**
77
122
  * Alias for userAttributes.urlPath except it can handle a full URL (optionally with host,
@@ -114,10 +159,13 @@ export interface GetContentOptions {
114
159
  /**
115
160
  * Mongodb style query of your data. E.g.:
116
161
  *
117
- * ```
118
- * &query.data.id=abc123
119
- * &query.data.myCustomField=someValue
120
- * &query.data.someNumber.$ne=20
162
+ * ```js
163
+ * query: {
164
+ * id: 'abc123',
165
+ * data: {
166
+ * myCustomField: { $gt: 20 },
167
+ * }
168
+ * }
121
169
  * ```
122
170
  *
123
171
  * See more info on MongoDB's query operators and format.
@@ -172,6 +220,7 @@ export interface GetContentOptions {
172
220
  /**
173
221
  * @package
174
222
  * @deprecated
223
+ * @hidden
175
224
  */
176
225
  alias?: string;
177
226
  fields?: string;
@@ -191,7 +240,10 @@ export interface GetContentOptions {
191
240
  * Affects HTML generation for specific targets.
192
241
  */
193
242
  format?: 'amp' | 'email' | 'html' | 'react' | 'solid';
194
- /** @deprecated */
243
+ /**
244
+ * @deprecated
245
+ * @hidden
246
+ */
195
247
  noWrap?: true;
196
248
  /**
197
249
  * @package
@@ -243,22 +295,60 @@ interface Map<K, V> {
243
295
  values(): IterableIterator<V>;
244
296
  [Symbol.iterator](): IterableIterator<[K, V]>;
245
297
  }
298
+ /**
299
+ * This is the interface for inputs in `Builder.registerComponent`
300
+ *
301
+ * ```js
302
+ * Builder.registerComponent(MyComponent, {
303
+ * inputs: [{ name: 'title', type: 'text' }] // <- Input[]
304
+ * })
305
+ * ```
306
+ *
307
+ * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
308
+ */
246
309
  export interface Input {
310
+ /** This is the name of the component prop this input represents */
247
311
  name: string;
312
+ /** A friendlier name to show in the UI if the component prop name is not ideal for end users */
248
313
  friendlyName?: string;
314
+ /** @hidden @deprecated */
249
315
  description?: string;
316
+ /** A default value to use */
250
317
  defaultValue?: any;
318
+ /**
319
+ * The type of input to use, such as 'text'
320
+ *
321
+ * See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
322
+ * and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
323
+ */
251
324
  type: string;
325
+ /** Is this input mandatory or not */
252
326
  required?: boolean;
327
+ /** @hidden */
253
328
  autoFocus?: boolean;
254
329
  subFields?: Input[];
330
+ /**
331
+ * Additional text to render in the UI to give guidance on how to use this
332
+ *
333
+ * @example
334
+ * ```js
335
+ * helperText: 'Be sure to use a proper URL, starting with "https://"'
336
+ * 111
337
+ */
255
338
  helperText?: string;
339
+ /** @hidden */
256
340
  allowedFileTypes?: string[];
341
+ /** @hidden */
257
342
  imageHeight?: number;
343
+ /** @hidden */
258
344
  imageWidth?: number;
345
+ /** @hidden */
259
346
  mediaHeight?: number;
347
+ /** @hidden */
260
348
  mediaWidth?: number;
349
+ /** @hidden */
261
350
  hideFromUI?: boolean;
351
+ /** @hidden */
262
352
  modelId?: string;
263
353
  /**
264
354
  * Number field type validation maximum accepted input
@@ -285,9 +375,13 @@ export interface Input {
285
375
  * to bubble up important inputs for locked groups, like text and images
286
376
  */
287
377
  bubble?: boolean;
378
+ /** @hidden */
288
379
  options?: {
289
380
  [key: string]: any;
290
381
  };
382
+ /**
383
+ * For "text" input type, specifying an enum will show a dropdown of options instead
384
+ */
291
385
  enum?: string[] | {
292
386
  label: string;
293
387
  value: any;
@@ -305,31 +399,82 @@ export interface Input {
305
399
  */
306
400
  message: string;
307
401
  };
402
+ /**
403
+ * Set this to `true` to put this under the "show more" section of
404
+ * the options editor. Useful for things that are more advanced
405
+ * or more rarely used and don't need to be too prominent
406
+ */
308
407
  advanced?: boolean;
408
+ /** @hidden */
309
409
  onChange?: Function | string;
410
+ /** @hidden */
310
411
  code?: boolean;
412
+ /** @hidden */
311
413
  richText?: boolean;
414
+ /** @hidden */
312
415
  showIf?: ((options: Map<string, any>) => boolean) | string;
416
+ /** @hidden */
313
417
  copyOnAdd?: boolean;
314
418
  }
419
+ /**
420
+ * This is the interface for the options for `Builder.registerComponent`
421
+ *
422
+ * ```js
423
+ * Builder.registerComponent(YourComponent, {
424
+ * // <- Component options
425
+ * })
426
+ * ```
427
+ *
428
+ * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
429
+ */
315
430
  export interface Component {
316
431
  /**
317
432
  * Name your component something unique, e.g. 'MyButton'. You can override built-in components
318
433
  * by registering a component with the same name, e.g. 'Text', to replace the built-in text component
319
434
  */
320
435
  name: string;
436
+ /** @hidden @deprecated */
321
437
  description?: string;
322
438
  /**
323
439
  * Link to a documentation page for this component
324
440
  */
325
441
  docsLink?: string;
442
+ /**
443
+ * Link to an image to be used as an icon for this component in Builder's editor
444
+ *
445
+ * @example
446
+ * ```js
447
+ * image: 'https://some-cdn.com/my-icon-for-this-component.png'
448
+ * ```
449
+ */
326
450
  image?: string;
327
451
  /**
328
- * Input schema for your component for users to fill in the options
452
+ * Link to a screenshot shown when user hovers over the component in Builder's editor
453
+ * use https://builder.io/upload to upload your screeshot, for easier resizing by Builder.
454
+ */
455
+ screenshot?: string;
456
+ /**
457
+ * Input schema for your component for users to fill in the options via a UI
458
+ * that translate to this components props
329
459
  */
330
460
  inputs?: Input[];
461
+ /** @hidden @deprecated */
331
462
  class?: any;
463
+ /** @hidden @deprecated */
332
464
  type?: 'angular' | 'webcomponent' | 'react' | 'vue';
465
+ /**
466
+ * Default styles to apply when droppged into the Builder.io editor
467
+ *
468
+ * @example
469
+ * ```js
470
+ * defaultStyles: {
471
+ * // large (default) breakpoint
472
+ * large: {
473
+ * backgroundColor: 'black'
474
+ * },
475
+ * }
476
+ * ```
477
+ */
333
478
  defaultStyles?: {
334
479
  [key: string]: string;
335
480
  };
@@ -339,6 +484,7 @@ export interface Component {
339
484
  * github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
340
485
  */
341
486
  canHaveChildren?: boolean;
487
+ /** @hidden */
342
488
  fragment?: boolean;
343
489
  /**
344
490
  * Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
@@ -349,7 +495,11 @@ export interface Component {
349
495
  * Default children
350
496
  */
351
497
  defaultChildren?: BuilderElement[];
498
+ /**
499
+ * Default options to merge in when creating this block
500
+ */
352
501
  defaults?: Partial<BuilderElement>;
502
+ /** @hidden @deprecated */
353
503
  hooks?: {
354
504
  [key: string]: string | Function;
355
505
  };
@@ -357,7 +507,9 @@ export interface Component {
357
507
  * Hide your component in editor, useful for gradually deprecating components
358
508
  */
359
509
  hideFromInsertMenu?: boolean;
510
+ /** Custom tag name (for custom webcomponents only) */
360
511
  tag?: string;
512
+ /** @hidden @deprecated */
361
513
  static?: boolean;
362
514
  /**
363
515
  * Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
@@ -403,7 +555,7 @@ export interface Component {
403
555
  */
404
556
  query?: any;
405
557
  };
406
- /** not yet implemented */
558
+ /** @hidden @deprecated */
407
559
  friendlyName?: string;
408
560
  /**
409
561
  * Use to restrict access to your component based on a the current user permissions
@@ -421,6 +573,29 @@ export interface InsertMenuItem {
421
573
  icon?: string;
422
574
  item: DeepPartial<BuilderElement>;
423
575
  }
576
+ /**
577
+ * Use this to register custom sections in the Insert menu, for instance
578
+ * to make new sections to organize your custom components
579
+ *
580
+ * ![Example of what a custom section looks like](https://cdn.builder.io/api/v1/image/assets%2F7f7bbcf72a1a4d72bac5daa359e7befd%2Fe5f2792e9c0f44ed89a9dcb77b945858)
581
+ *
582
+ * @example
583
+ * ```js
584
+ * Builder.register('insertMenu', {
585
+ * name: 'Our components',
586
+ * items: [
587
+ * { name: 'Hero' },
588
+ * { name: 'Double Columns' },
589
+ * { name: 'Triple Columns' },
590
+ * { name: 'Dynamic Columns' },
591
+ * ],
592
+ * })
593
+ * ```
594
+ *
595
+ * You can make as many custom sections as you like
596
+ *
597
+ * See a complete usage example [here](https://github.com/builderio/builder/blob/main/examples/react-design-system/src/builder-settings.js)
598
+ */
424
599
  export interface InsertMenuConfig {
425
600
  name: string;
426
601
  priority?: number;
@@ -439,6 +614,10 @@ export interface Action {
439
614
  export declare class Builder {
440
615
  protected request?: IncomingMessage | undefined;
441
616
  protected response?: ServerResponse | undefined;
617
+ /**
618
+ * @hidden
619
+ * @deprecated. This is buggy, and always behind by a version.
620
+ */
442
621
  static VERSION: string;
443
622
  static components: Component[];
444
623
  static singletonInstance: Builder;
@@ -485,6 +664,12 @@ export declare class Builder {
485
664
  static previewingModel: string | false | null;
486
665
  static settings: Settings;
487
666
  static settingsChange: BehaviorSubject<any, any>;
667
+ /**
668
+ * @deprecated
669
+ * @hidden
670
+ *
671
+ * Use Builder.register('editor.settings', {}) instead.
672
+ */
488
673
  static set(settings: Settings): void;
489
674
  static import(packageName: string): any;
490
675
  static isEditing: boolean;