mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
Fix ws init (#6109)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
a8aaf5bd74
commit
9cc64569ba
@ -143,8 +143,8 @@ export class WorkspaceInitializer {
|
|||||||
const buffer = Buffer.from(await resp.arrayBuffer())
|
const buffer = Buffer.from(await resp.arrayBuffer())
|
||||||
await this.storageAdapter.put(this.ctx, this.wsUrl, id, buffer, step.contentType, buffer.length)
|
await this.storageAdapter.put(this.ctx, this.wsUrl, id, buffer, step.contentType, buffer.length)
|
||||||
if (step.resultVariable !== undefined) {
|
if (step.resultVariable !== undefined) {
|
||||||
vars[step.resultVariable] = id
|
vars[`\${${step.resultVariable}}`] = id
|
||||||
vars[`${step.resultVariable}_size`] = buffer.length
|
vars[`\${${step.resultVariable}_size}`] = buffer.length
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Upload failed', error)
|
logger.error('Upload failed', error)
|
||||||
@ -159,7 +159,7 @@ export class WorkspaceInitializer {
|
|||||||
throw new Error(`Document not found: ${JSON.stringify(query)}`)
|
throw new Error(`Document not found: ${JSON.stringify(query)}`)
|
||||||
}
|
}
|
||||||
if (step.resultVariable !== undefined) {
|
if (step.resultVariable !== undefined) {
|
||||||
vars[step.resultVariable] = res
|
vars[`\${${step.resultVariable}}`] = res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ export class WorkspaceInitializer {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const _id = generateId<T>()
|
const _id = generateId<T>()
|
||||||
if (step.resultVariable !== undefined) {
|
if (step.resultVariable !== undefined) {
|
||||||
vars[step.resultVariable] = _id
|
vars[`\${${step.resultVariable}}`] = _id
|
||||||
}
|
}
|
||||||
const data = await this.fillPropsWithMarkdown(
|
const data = await this.fillPropsWithMarkdown(
|
||||||
{ ...(defaults.get(step._class) ?? {}), ...step.data },
|
{ ...(defaults.get(step._class) ?? {}), ...step.data },
|
||||||
@ -226,8 +226,15 @@ export class WorkspaceInitializer {
|
|||||||
) {
|
) {
|
||||||
throw new Error('Add collection step must have attachedTo, attachedToClass, collection and space')
|
throw new Error('Add collection step must have attachedTo, attachedToClass, collection and space')
|
||||||
}
|
}
|
||||||
return (await this.client.addCollection(_class, space, attachedTo, attachedToClass, collection, props),
|
return (await this.client.addCollection(
|
||||||
_id) as unknown as Ref<T>
|
_class,
|
||||||
|
space,
|
||||||
|
attachedTo,
|
||||||
|
attachedToClass,
|
||||||
|
collection,
|
||||||
|
props,
|
||||||
|
_id as Ref<AttachedDoc> | undefined
|
||||||
|
)) as unknown as Ref<T>
|
||||||
} else {
|
} else {
|
||||||
const { space, ...props } = data
|
const { space, ...props } = data
|
||||||
if (space === undefined) {
|
if (space === undefined) {
|
||||||
@ -298,7 +305,7 @@ export class WorkspaceInitializer {
|
|||||||
const matched = fieldRegexp.exec(value)
|
const matched = fieldRegexp.exec(value)
|
||||||
if (matched === null) break
|
if (matched === null) break
|
||||||
const result = vars[matched[0]]
|
const result = vars[matched[0]]
|
||||||
if (result === undefined || typeof result !== 'string') {
|
if (result === undefined) {
|
||||||
throw new Error(`Variable ${matched[0]} not found`)
|
throw new Error(`Variable ${matched[0]} not found`)
|
||||||
} else {
|
} else {
|
||||||
value = value.replaceAll(matched[0], result)
|
value = value.replaceAll(matched[0], result)
|
||||||
|
Loading…
Reference in New Issue
Block a user