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())
|
||||
await this.storageAdapter.put(this.ctx, this.wsUrl, id, buffer, step.contentType, buffer.length)
|
||||
if (step.resultVariable !== undefined) {
|
||||
vars[step.resultVariable] = id
|
||||
vars[`${step.resultVariable}_size`] = buffer.length
|
||||
vars[`\${${step.resultVariable}}`] = id
|
||||
vars[`\${${step.resultVariable}_size}`] = buffer.length
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Upload failed', error)
|
||||
@ -159,7 +159,7 @@ export class WorkspaceInitializer {
|
||||
throw new Error(`Document not found: ${JSON.stringify(query)}`)
|
||||
}
|
||||
if (step.resultVariable !== undefined) {
|
||||
vars[step.resultVariable] = res
|
||||
vars[`\${${step.resultVariable}}`] = res
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ export class WorkspaceInitializer {
|
||||
): Promise<void> {
|
||||
const _id = generateId<T>()
|
||||
if (step.resultVariable !== undefined) {
|
||||
vars[step.resultVariable] = _id
|
||||
vars[`\${${step.resultVariable}}`] = _id
|
||||
}
|
||||
const data = await this.fillPropsWithMarkdown(
|
||||
{ ...(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')
|
||||
}
|
||||
return (await this.client.addCollection(_class, space, attachedTo, attachedToClass, collection, props),
|
||||
_id) as unknown as Ref<T>
|
||||
return (await this.client.addCollection(
|
||||
_class,
|
||||
space,
|
||||
attachedTo,
|
||||
attachedToClass,
|
||||
collection,
|
||||
props,
|
||||
_id as Ref<AttachedDoc> | undefined
|
||||
)) as unknown as Ref<T>
|
||||
} else {
|
||||
const { space, ...props } = data
|
||||
if (space === undefined) {
|
||||
@ -298,7 +305,7 @@ export class WorkspaceInitializer {
|
||||
const matched = fieldRegexp.exec(value)
|
||||
if (matched === null) break
|
||||
const result = vars[matched[0]]
|
||||
if (result === undefined || typeof result !== 'string') {
|
||||
if (result === undefined) {
|
||||
throw new Error(`Variable ${matched[0]} not found`)
|
||||
} else {
|
||||
value = value.replaceAll(matched[0], result)
|
||||
|
Loading…
Reference in New Issue
Block a user