@combeenation/custom-code-sdk 0.0.1-alpha3 → 0.0.1-alpha5

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.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
+ import { CheckoutProductCustomFields } from './types/checkout';
2
+ import { DiyShopCheckoutJson } from './types/checkout';
3
+ import { ShopifyCheckoutJson } from './types/checkout';
4
+ import { Shopware6CheckoutJson } from './types/checkout';
1
5
  import { z } from 'zod';
2
6
 
3
7
  export declare class Button {
4
8
  #private;
5
9
  readonly id: CtrlId;
6
- readonly sdkBridgeVersion = "v1";
7
10
  constructor(id: CtrlId);
8
11
  onRendered(callback: OnRenderedCallback<HTMLButtonElement>): CallbackUnsubscribeOption;
9
12
  onClick(callback: OnClickCallback): CallbackUnsubscribeOption;
@@ -15,19 +18,10 @@ declare type CallbackUnsubscribeOption = {
15
18
  unsubscribe: () => void;
16
19
  };
17
20
 
18
- /**
19
- * Why we need this?
20
- *
21
- * Our custom code SDK is using the `ConfiguratorClient` as its main gateway to communicate with cmps. It comes with the
22
- * `ConfiguratorClient` built in and only knows about the API of the version is was built with.
23
- *
24
- * Therefore, we'll always have to support older versions of the public API for custom code as well at "system runtime".
25
- *
26
- * Custom code shall always access the `ConfiguratorClient` via some well defined "gateway fn" like
27
- * `window.Cbn.getCustomCodeSdkBridge().createCfgrClient` which is responsible for returning the correct versioned API
28
- * e.g. by "hotpatching" the returned runtime object based on the requested version.
29
- */
21
+ declare type CfgrClient = NonNullable<typeof client>;
22
+
30
23
  declare interface CfgrClientApi_v1 {
24
+ finishConfiguration: (input?: string) => Promise<FinishResult>;
31
25
  onAnyCmpValueChanged<TInput extends ValueComponent_2>(listener: CmpValuesChangedListener<TInput['name']>, components: TInput[], lazy?: boolean): Promise<void>;
32
26
  getCmpValue<T extends CmpValue_2>(cmpName: CmpName_2): Promise<T | undefined>;
33
27
  onCmpValueChanged<TValue extends CmpValue_2>(cmpName: CmpName_2, listener: CmpValueChangedListener_2<TValue>, condition?: CmpValueChangedCondition_2<TValue>, callImmediately?: boolean): Promise<void>;
@@ -36,12 +30,13 @@ declare interface CfgrClientApi_v1 {
36
30
  export declare class Checkbox {
37
31
  #private;
38
32
  readonly id: CtrlId;
39
- readonly sdkBridgeVersion = "v1";
40
33
  constructor(id: CtrlId);
41
34
  onRendered(callback: OnRenderedCallback<HTMLLabelElement>): CallbackUnsubscribeOption;
42
35
  setVisible(visible: boolean): Promise<void>;
43
36
  }
44
37
 
38
+ export { CheckoutProductCustomFields }
39
+
45
40
  declare const client: CfgrClientApi_v1 | undefined;
46
41
 
47
42
  declare type CmpName = string;
@@ -79,7 +74,6 @@ declare interface CmpValuesChangedListener<TName extends string = string> {
79
74
  export declare class Collapsible {
80
75
  #private;
81
76
  readonly id: CtrlId;
82
- readonly sdkBridgeVersion = "v1";
83
77
  constructor(id: CtrlId);
84
78
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
85
79
  setVisible(visible: boolean): Promise<void>;
@@ -90,10 +84,28 @@ declare type CtrlId = z.infer<typeof ZCtrlId>;
90
84
  export declare class CustomControl {
91
85
  #private;
92
86
  readonly id: CtrlId;
93
- readonly sdkBridgeVersion = "v1";
94
87
  constructor(id: CtrlId);
88
+ /**
89
+ * Things to mention when writing docs:
90
+ * - Given `el` is only disconnected when ctrl is hidden
91
+ * -> Event listener on that element shall only be installed once in custom code
92
+ * Explicitly mention that this is only the case for `customCtrl.renderFn` and not for `otherCtrls.onRendered`.
93
+ * - Assigning a new fn does not trigger a re-render
94
+ * - Explain, when this fn is being called (automatically on show, manually on `.render()`)
95
+ * - Explain, why this should be used instead of a pattern like the following:
96
+ * ```ts
97
+ * const el = myCtrl.getElement();
98
+ * el.innerHTML = '...';
99
+ * ```
100
+ * - Explain difference to `onRendered` (see comments on `useCustomCodeSdkBridgeStoreBase`)
101
+ * - ...
102
+ */
95
103
  set renderFn(callback: CustomCtrlRenderFn);
96
- render(): Promise<void>;
104
+ /**
105
+ * @param renderFn Convenience param which allows setting the `renderFn` and triggering a render in one call.
106
+ * The `renderFn` will be permanently installed and will override any existing `renderFn`.
107
+ */
108
+ render(renderFn?: CustomCtrlRenderFn): Promise<void>;
97
109
  getElement(): HTMLElement | undefined;
98
110
  setVisible(visible: boolean): Promise<void>;
99
111
  }
@@ -103,24 +115,41 @@ declare type CustomCtrlRenderFn = (element: HTMLDivElement, rawHtml: string | un
103
115
  export declare class Dataview {
104
116
  #private;
105
117
  readonly id: CtrlId;
106
- readonly sdkBridgeVersion = "v1";
107
118
  constructor(id: CtrlId);
108
119
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
109
120
  setVisible(visible: boolean): Promise<void>;
110
121
  }
111
122
 
123
+ export { DiyShopCheckoutJson }
124
+
125
+ export declare const finishConfiguration: CfgrClient['finishConfiguration'];
126
+
127
+ /**
128
+ * Why we need this?
129
+ *
130
+ * Our custom code SDK is using the `ConfiguratorClient` as its main gateway to communicate with cmps. It comes with the
131
+ * `ConfiguratorClient` built in and only knows about the API of the version is was built with.
132
+ *
133
+ * Therefore, we'll always have to support older versions of the public API for custom code as well at "system runtime".
134
+ *
135
+ * Custom code shall always access the `ConfiguratorClient` via some well defined "gateway fn" like
136
+ * `window.Cbn.getCustomCodeSdkBridge().createCfgrClient` which is responsible for returning the correct versioned API
137
+ * e.g. by "hotpatching" the returned runtime object based on the requested version.
138
+ */
139
+ declare type FinishResult = {
140
+ newEditCfgnUrl: string;
141
+ actionResults: {};
142
+ };
143
+
112
144
  export declare class Input {
113
145
  #private;
114
146
  readonly id: CtrlId;
115
- readonly sdkBridgeVersion = "v1";
116
147
  constructor(id: CtrlId);
117
148
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
118
149
  setVisible(visible: boolean): Promise<void>;
119
150
  }
120
151
 
121
- declare type OnAnyCmpValueChanged = NonNullable<typeof client>['onAnyCmpValueChanged'];
122
-
123
- export declare const onAnyCmpValueChanged: OnAnyCmpValueChanged;
152
+ export declare const onAnyCmpValueChanged: CfgrClient['onAnyCmpValueChanged'];
124
153
 
125
154
  declare type OnClickCallback = () => void;
126
155
 
@@ -129,16 +158,18 @@ declare type OnRenderedCallback<T extends HTMLElement = HTMLElement> = (element:
129
158
  export declare class Panel {
130
159
  #private;
131
160
  readonly id: CtrlId;
132
- readonly sdkBridgeVersion = "v1";
133
161
  constructor(id: CtrlId);
134
162
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
135
163
  setVisible(visible: boolean): Promise<void>;
136
164
  }
137
165
 
166
+ export { ShopifyCheckoutJson }
167
+
168
+ export { Shopware6CheckoutJson }
169
+
138
170
  declare class Text_2 {
139
171
  #private;
140
172
  readonly id: CtrlId;
141
- readonly sdkBridgeVersion = "v1";
142
173
  constructor(id: CtrlId);
143
174
  onRendered(callback: OnRenderedCallback<HTMLSpanElement>): CallbackUnsubscribeOption;
144
175
  setVisible(visible: boolean): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/custom-code-sdk",
3
- "version": "0.0.1-alpha3",
3
+ "version": "0.0.1-alpha5",
4
4
  "description": "Combeenation custom code SDK package",
5
5
  "keywords": [],
6
6
  "homepage": "",