@embeddable.com/sdk-core 3.1.5 → 3.1.7
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/lib/index.esm.js +27 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +27 -5
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/push.ts +4 -2
- package/src/validate.ts +28 -3
- package/templates/component.tsx.template +17 -1
package/package.json
CHANGED
package/src/push.ts
CHANGED
|
@@ -41,14 +41,16 @@ export default async () => {
|
|
|
41
41
|
token,
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
+
const workspacePreviewUrl = `${config.previewBaseUrl}/workspace/${workspaceId}`
|
|
45
|
+
|
|
44
46
|
await buildArchive(config);
|
|
45
47
|
spinnerPushing = ora(
|
|
46
|
-
`Publishing to ${workspaceName} using ${
|
|
48
|
+
`Publishing to ${workspaceName} using ${workspacePreviewUrl}...`,
|
|
47
49
|
).start();
|
|
48
50
|
|
|
49
51
|
await sendBuild(config, { workspaceId, token });
|
|
50
52
|
spinnerPushing.succeed(
|
|
51
|
-
`Published to ${workspaceName} using ${
|
|
53
|
+
`Published to ${workspaceName} using ${workspacePreviewUrl}`,
|
|
52
54
|
);
|
|
53
55
|
} catch (error: any) {
|
|
54
56
|
spinnerPushing?.fail("Publishing failed");
|
package/src/validate.ts
CHANGED
|
@@ -75,9 +75,21 @@ export async function dataModelsValidation(filesList: [string, string][]) {
|
|
|
75
75
|
|
|
76
76
|
const cube = YAML.parse(fileContentRaw);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (!cube?.cubes && !cube?.views) {
|
|
79
|
+
return [`${filePath}: At least one cubes or views must be defined`];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const cubeModelSafeParse = cubeModelSchema.safeParse(cube);
|
|
83
|
+
const viewModelSafeParse = viewModelSchema.safeParse(cube);
|
|
84
|
+
|
|
85
|
+
if (cube.cubes && !cubeModelSafeParse.success) {
|
|
86
|
+
errorFormatter(cubeModelSafeParse.error.issues).forEach((error) => {
|
|
87
|
+
errors.push(`${filePath}: ${error}`);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (cube.views && !viewModelSafeParse.success) {
|
|
92
|
+
errorFormatter(viewModelSafeParse.error.issues).forEach((error) => {
|
|
81
93
|
errors.push(`${filePath}: ${error}`);
|
|
82
94
|
});
|
|
83
95
|
}
|
|
@@ -172,6 +184,19 @@ const cubeModelSchema = z
|
|
|
172
184
|
},
|
|
173
185
|
);
|
|
174
186
|
|
|
187
|
+
const viewModelSchema = z.object({
|
|
188
|
+
views: z.object({
|
|
189
|
+
name: z.string(),
|
|
190
|
+
cubes: z
|
|
191
|
+
.object({
|
|
192
|
+
join_path: z.string(),
|
|
193
|
+
})
|
|
194
|
+
.array()
|
|
195
|
+
})
|
|
196
|
+
.array()
|
|
197
|
+
.min(1),
|
|
198
|
+
});
|
|
199
|
+
|
|
175
200
|
const securityContextSchema = z.array(
|
|
176
201
|
z.object({
|
|
177
202
|
name: z.string(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Watch, Host, Prop, Event, EventEmitter, h } from '@stencil/core';
|
|
1
|
+
import { Component, Watch, Host, Prop, Event, EventEmitter, h, Listen } from '@stencil/core';
|
|
2
2
|
{{RENDER_IMPORT}}
|
|
3
3
|
|
|
4
4
|
@Component({
|
|
@@ -9,6 +9,7 @@ import { Component, Watch, Host, Prop, Event, EventEmitter, h } from '@stencil/c
|
|
|
9
9
|
export class EmbeddableComponent {
|
|
10
10
|
|
|
11
11
|
private rootElement?: HTMLDivElement;
|
|
12
|
+
private updatePropsEventDispatched?: boolean;
|
|
12
13
|
|
|
13
14
|
@Prop() componentName: string;
|
|
14
15
|
@Prop() props: string = '{}';
|
|
@@ -44,6 +45,21 @@ export class EmbeddableComponent {
|
|
|
44
45
|
detail: JSON.parse(this.props),
|
|
45
46
|
});
|
|
46
47
|
this.rootElement.dispatchEvent(event);
|
|
48
|
+
this.updatePropsEventDispatched = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Listen('embeddable-event:update-props-listen', {target: 'window'})
|
|
52
|
+
handleUpdatePropsListen(e) {
|
|
53
|
+
const componentId = e.detail.componentId;
|
|
54
|
+
const props = JSON.parse(this.props);
|
|
55
|
+
|
|
56
|
+
if(this.updatePropsEventDispatched && componentId === props.componentId) {
|
|
57
|
+
const event = new CustomEvent('embeddable-event:update-props', {
|
|
58
|
+
bubbles: false,
|
|
59
|
+
detail: props,
|
|
60
|
+
});
|
|
61
|
+
this.rootElement.dispatchEvent(event);
|
|
62
|
+
}
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
render() {
|