@milaboratories/pl-middle-layer 1.24.0 → 1.25.1
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/block_registry/watcher.d.ts +13 -5
- package/dist/block_registry/watcher.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1009 -973
- package/dist/index.mjs.map +1 -1
- package/dist/middle_layer/project.d.ts +3 -1
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project_overview.d.ts.map +1 -1
- package/dist/model/project_model.d.ts +1 -1
- package/dist/model/project_model.d.ts.map +1 -1
- package/dist/mutator/project.d.ts +5 -2
- package/dist/mutator/project.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/block_registry/watcher.ts +101 -69
- package/src/middle_layer/project.ts +10 -1
- package/src/middle_layer/project_overview.ts +24 -4
- package/src/model/project_model.ts +3 -2
- package/src/mutator/project.ts +47 -8
|
@@ -5,7 +5,7 @@ import { BlockPackSpecAny } from '../model';
|
|
|
5
5
|
import { SynchronizedTreeState } from '@milaboratories/pl-tree';
|
|
6
6
|
import { NavigationState } from '@milaboratories/pl-model-common';
|
|
7
7
|
import { FrontendData } from '../model/frontend';
|
|
8
|
-
import { ProjectOverview, AuthorMarker, BlockStateInternal } from '@milaboratories/pl-model-middle-layer';
|
|
8
|
+
import { ProjectOverview, AuthorMarker, BlockStateInternal, BlockSettings } from '@milaboratories/pl-model-middle-layer';
|
|
9
9
|
/** Data access object, to manipulate and read single opened (!) project data. */
|
|
10
10
|
export declare class Project {
|
|
11
11
|
private readonly env;
|
|
@@ -86,6 +86,8 @@ export declare class Project {
|
|
|
86
86
|
* in collaborative editing scenario.
|
|
87
87
|
* */
|
|
88
88
|
setBlockArgsAndUiState(blockId: string, args: unknown, uiState: unknown, author?: AuthorMarker): Promise<void>;
|
|
89
|
+
/** Update block settings */
|
|
90
|
+
setBlockSettings(blockId: string, newValue: BlockSettings): Promise<void>;
|
|
89
91
|
/** Resets arguments and ui state of the block to initial state */
|
|
90
92
|
resetBlockArgsAndUiState(blockId: string, author?: AuthorMarker): Promise<void>;
|
|
91
93
|
private getBlockComputables;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/middle_layer/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAOL,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAwB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/middle_layer/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAOL,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAwB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,uCAAuC,CAAC;AAS/C,iFAAiF;AACjF,qBAAa,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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project_overview.d.ts","sourceRoot":"","sources":["../../src/middle_layer/project_overview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAc,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAcjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"project_overview.d.ts","sourceRoot":"","sources":["../../src/middle_layer/project_overview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAc,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAcjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAML,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAM/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAyBvD,sEAAsE;AACtE,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,sBAAsB,GAC1B,uBAAuB,CAAC,eAAe,CAAC,CAuL1C"}
|
|
@@ -63,7 +63,7 @@ export declare const ServiceTemplateCacheFieldPrefix = "__serviceTemplate_";
|
|
|
63
63
|
export declare function getServiceTemplateField(hash: string): string;
|
|
64
64
|
export interface ProjectField {
|
|
65
65
|
blockId: string;
|
|
66
|
-
fieldName: 'blockPack' | 'prodArgs' | 'currentArgs' | 'prodCtx' | 'prodUiCtx' | 'prodOutput' | 'prodCtxPrevious' | 'prodUiCtxPrevious' | 'prodOutputPrevious' | 'stagingCtx' | 'stagingUiCtx' | 'stagingOutput' | 'stagingCtxPrevious' | 'stagingUiCtxPrevious' | 'stagingOutputPrevious';
|
|
66
|
+
fieldName: 'blockPack' | 'blockSettings' | 'prodArgs' | 'currentArgs' | 'prodCtx' | 'prodUiCtx' | 'prodOutput' | 'prodCtxPrevious' | 'prodUiCtxPrevious' | 'prodOutputPrevious' | 'stagingCtx' | 'stagingUiCtx' | 'stagingOutput' | 'stagingCtxPrevious' | 'stagingUiCtxPrevious' | 'stagingOutputPrevious';
|
|
67
67
|
}
|
|
68
68
|
export declare function projectFieldName(blockId: string, fieldName: ProjectField['fieldName']): string;
|
|
69
69
|
export declare function parseProjectField(name: string): ProjectField | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project_model.d.ts","sourceRoot":"","sources":["../../src/model/project_model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,gBAAgB,IAAI,yBAAyB,EAC7C,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,gBAAiB,SAAQ,yBAAyB;IACjE,2BAA2B;IAC3B,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,2DAA2D;AAC3D,MAAM,WAAW,KAAK;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;SAGK;IACL,KAAK,EAAE,MAAM,CAAC;IAEd,sCAAsC;IACtC,aAAa,EAAE,kBAAkB,CAAC;CACnC;AAED,qCAAqC;AACrC,MAAM,WAAW,UAAU;IACzB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd,aAAa;IACb,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,qBAAqB,EAAE,gBAEnC,CAAC;AAEF,sCA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GACX,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,oBAAoB,GACpB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,oBAAoB,GACpB,sBAAsB,GACtB,uBAAuB,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,MAAM,CAE9F;AAKD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAKxE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyRef, AnyResourceRef, PlClient, PlTransaction, ResourceId } from '@milaboratories/pl-client';
|
|
2
2
|
import { Block, ProjectStructure, ProjectField, ProjectRenderingState } from '../model/project_model';
|
|
3
3
|
import { BlockPackSpecPrepared } from '../model';
|
|
4
|
-
import { AuthorMarker, ProjectMeta } from '@milaboratories/pl-model-middle-layer';
|
|
4
|
+
import { AuthorMarker, BlockSettings, ProjectMeta } from '@milaboratories/pl-model-middle-layer';
|
|
5
5
|
type FieldStatus = 'NotReady' | 'Ready' | 'Error';
|
|
6
6
|
interface BlockFieldState {
|
|
7
7
|
modCount: number;
|
|
@@ -58,7 +58,7 @@ export declare class ProjectMutator {
|
|
|
58
58
|
/** Set blocks will be assigned current mutator author marker on save */
|
|
59
59
|
private readonly blocksWithChangedInputs;
|
|
60
60
|
constructor(rid: ResourceId, tx: PlTransaction, author: AuthorMarker | undefined, schema: string, lastModified: number, meta: ProjectMeta, struct: ProjectStructure, renderingState: Omit<ProjectRenderingState, 'blocksInLimbo'>, blocksInLimbo: Set<string>, blockInfos: Map<string, BlockInfo>, blockFrontendStates: Map<string, string>, ctxExportTplHolder: AnyResourceRef);
|
|
61
|
-
private
|
|
61
|
+
private fixProblemsAndMigrate;
|
|
62
62
|
get wasModified(): boolean;
|
|
63
63
|
get structure(): ProjectStructure;
|
|
64
64
|
private stagingGraph;
|
|
@@ -68,6 +68,8 @@ export declare class ProjectMutator {
|
|
|
68
68
|
private getPendingProductionGraph;
|
|
69
69
|
private getActualProductionGraph;
|
|
70
70
|
private getBlockInfo;
|
|
71
|
+
private createJsonFieldValueByContent;
|
|
72
|
+
private createJsonFieldValue;
|
|
71
73
|
private getBlock;
|
|
72
74
|
private setBlockFieldObj;
|
|
73
75
|
private setBlockField;
|
|
@@ -82,6 +84,7 @@ export declare class ProjectMutator {
|
|
|
82
84
|
/** Optimally sets inputs for multiple blocks in one go */
|
|
83
85
|
setArgs(requests: SetArgsRequest[]): void;
|
|
84
86
|
setUiState(blockId: string, newState: string | undefined): void;
|
|
87
|
+
setBlockSettings(blockId: string, newValue: BlockSettings): void;
|
|
85
88
|
/** Update block label */
|
|
86
89
|
private createCtx;
|
|
87
90
|
private exportCtx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/mutator/project.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EASd,QAAQ,EACR,aAAa,EACb,UAAU,EAEX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,EAEL,gBAAgB,EAGhB,YAAY,EAEZ,qBAAqB,EAetB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/mutator/project.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EASd,QAAQ,EACR,aAAa,EACb,UAAU,EAEX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,EAEL,gBAAgB,EAGhB,YAAY,EAEZ,qBAAqB,EAetB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EACL,YAAY,EACZ,aAAa,EAEb,WAAW,EACZ,MAAM,uCAAuC,CAAC;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AC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"yaml": "^2.6.1",
|
|
30
30
|
"zod": "~3.23.8",
|
|
31
31
|
"@milaboratories/pl-http": "^1.0.2",
|
|
32
|
-
"@milaboratories/computable": "^2.3.4",
|
|
33
|
-
"@platforma-sdk/block-tools": "^2.5.3",
|
|
34
32
|
"@milaboratories/resolve-helper": "^1.0.2",
|
|
35
|
-
"@
|
|
36
|
-
"@milaboratories/pl-model-common": "^1.10.3",
|
|
33
|
+
"@platforma-sdk/block-tools": "^2.5.5",
|
|
37
34
|
"@milaboratories/pl-client": "^2.7.2",
|
|
35
|
+
"@milaboratories/pl-drivers": "^1.5.9",
|
|
36
|
+
"@milaboratories/computable": "^2.3.4",
|
|
37
|
+
"@milaboratories/pl-model-middle-layer": "^1.7.0",
|
|
38
38
|
"@milaboratories/pl-model-backend": "^1.0.1",
|
|
39
39
|
"@milaboratories/pl-tree": "^1.4.21",
|
|
40
|
-
"@platforma-sdk/model": "^1.21.20",
|
|
41
|
-
"@milaboratories/pl-model-middle-layer": "^1.6.11",
|
|
42
40
|
"@platforma-sdk/workflow-tengo": "2.9.6",
|
|
41
|
+
"@milaboratories/pl-model-common": "^1.10.3",
|
|
43
42
|
"@milaboratories/ts-helpers": "^1.1.3",
|
|
43
|
+
"@platforma-sdk/model": "^1.21.20",
|
|
44
44
|
"@milaboratories/pl-config": "^1.3.3",
|
|
45
45
|
"@milaboratories/pl-local": "^1.10.0"
|
|
46
46
|
},
|
|
@@ -2,17 +2,19 @@ import { PollComputablePool, PollPoolOps } from '@milaboratories/computable';
|
|
|
2
2
|
import {
|
|
3
3
|
AnyChannel,
|
|
4
4
|
BlockPackFromRegistryV2,
|
|
5
|
-
blockPackIdEquals,
|
|
6
5
|
blockPackIdToString,
|
|
7
6
|
BlockPackSpec,
|
|
7
|
+
BlockSettings,
|
|
8
|
+
UpdateSuggestions,
|
|
8
9
|
StableChannel
|
|
9
10
|
} from '@milaboratories/pl-model-middle-layer';
|
|
10
11
|
import { Dispatcher } from 'undici';
|
|
11
12
|
import { getDevV1PacketMtime, getDevV2PacketMtime } from './registry';
|
|
12
13
|
import { tryLoadPackDescription } from '@platforma-sdk/block-tools';
|
|
13
|
-
import {
|
|
14
|
+
import { MiLogger } from '@milaboratories/ts-helpers';
|
|
14
15
|
import { V2RegistryProvider } from './registry-v2-provider';
|
|
15
16
|
import semver from 'semver';
|
|
17
|
+
import canonicalize from 'canonicalize';
|
|
16
18
|
|
|
17
19
|
export const DefaultBlockUpdateWatcherOps: PollPoolOps = {
|
|
18
20
|
minDelay: 1500
|
|
@@ -25,9 +27,19 @@ export type BlockUpdateWatcherOps = Partial<PollPoolOps> & {
|
|
|
25
27
|
|
|
26
28
|
const NoUpdatesKey = '__no_updates__';
|
|
27
29
|
|
|
30
|
+
export type CheckForUpdateRequest = {
|
|
31
|
+
currentSpec: BlockPackSpec;
|
|
32
|
+
settings: BlockSettings;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type CheckForUpdateResponse = {
|
|
36
|
+
suggestions: UpdateSuggestions;
|
|
37
|
+
mainSuggestion?: BlockPackSpec;
|
|
38
|
+
};
|
|
39
|
+
|
|
28
40
|
export class BlockUpdateWatcher extends PollComputablePool<
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
CheckForUpdateRequest,
|
|
42
|
+
CheckForUpdateResponse
|
|
31
43
|
> {
|
|
32
44
|
private readonly http?: Dispatcher;
|
|
33
45
|
private readonly preferredUpdateChannel?: string;
|
|
@@ -42,128 +54,148 @@ export class BlockUpdateWatcher extends PollComputablePool<
|
|
|
42
54
|
this.preferredUpdateChannel = ops.preferredUpdateChannel;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
|
-
protected getKey(req:
|
|
46
|
-
switch (req.type) {
|
|
57
|
+
protected getKey(req: CheckForUpdateRequest): string {
|
|
58
|
+
switch (req.currentSpec.type) {
|
|
47
59
|
case 'dev-v1':
|
|
48
|
-
return `dev_1_${req.folder}_${req.mtime}`;
|
|
60
|
+
return `dev_1_${req.currentSpec.folder}_${req.currentSpec.mtime}`;
|
|
49
61
|
case 'dev-v2':
|
|
50
|
-
return `dev_2_${req.folder}_${req.mtime}`;
|
|
62
|
+
return `dev_2_${req.currentSpec.folder}_${req.currentSpec.mtime}`;
|
|
51
63
|
case 'from-registry-v2':
|
|
52
|
-
return `from_registry_v2_${req
|
|
64
|
+
return `from_registry_v2_${canonicalize(req)!}`;
|
|
53
65
|
default:
|
|
54
66
|
return NoUpdatesKey;
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
protected async readValue(req:
|
|
70
|
+
protected async readValue(req: CheckForUpdateRequest): Promise<CheckForUpdateResponse> {
|
|
59
71
|
try {
|
|
60
|
-
|
|
72
|
+
const cSpec = req.currentSpec;
|
|
73
|
+
switch (cSpec.type) {
|
|
61
74
|
case 'dev-v1': {
|
|
62
75
|
try {
|
|
63
|
-
const mtime = await getDevV1PacketMtime(
|
|
64
|
-
if (mtime ===
|
|
65
|
-
else return { ...
|
|
76
|
+
const mtime = await getDevV1PacketMtime(cSpec.folder);
|
|
77
|
+
if (mtime === cSpec.mtime) return { suggestions: [] };
|
|
78
|
+
else return { mainSuggestion: { ...cSpec, mtime }, suggestions: [] };
|
|
66
79
|
} catch (err: unknown) {
|
|
67
80
|
this.logger.warn(err);
|
|
68
|
-
return
|
|
81
|
+
return { suggestions: [] };
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
case 'dev-v2': {
|
|
73
86
|
try {
|
|
74
|
-
const description = await tryLoadPackDescription(
|
|
75
|
-
if (description === undefined) return
|
|
87
|
+
const description = await tryLoadPackDescription(cSpec.folder, this.logger);
|
|
88
|
+
if (description === undefined) return { suggestions: [] };
|
|
76
89
|
const mtime = await getDevV2PacketMtime(description);
|
|
77
|
-
if (mtime ===
|
|
78
|
-
else return { ...
|
|
90
|
+
if (mtime === cSpec.mtime) return { suggestions: [] };
|
|
91
|
+
else return { mainSuggestion: { ...cSpec, mtime: mtime }, suggestions: [] };
|
|
79
92
|
} catch (err: unknown) {
|
|
80
93
|
this.logger.warn(err);
|
|
81
|
-
return
|
|
94
|
+
return { suggestions: [] };
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
case 'from-registry-v2': {
|
|
86
99
|
try {
|
|
87
|
-
const
|
|
100
|
+
const { versionLock, skipVersion } = req.settings;
|
|
101
|
+
if (versionLock === 'patch') return { suggestions: [] };
|
|
102
|
+
const registry = this.registryProvider.getRegistry(cSpec.registryUrl);
|
|
88
103
|
let spec: BlockPackSpec | undefined;
|
|
104
|
+
let channel: string | undefined;
|
|
89
105
|
|
|
90
|
-
if (
|
|
91
|
-
const a1 = await registry.getLatestOverview(
|
|
92
|
-
if (a1)
|
|
106
|
+
if (cSpec.channel === undefined) {
|
|
107
|
+
const a1 = await registry.getLatestOverview(cSpec.id, StableChannel);
|
|
108
|
+
if (a1) channel = StableChannel;
|
|
93
109
|
else {
|
|
94
110
|
// forcing update from non-existent channel to stable
|
|
95
|
-
const a2 = await registry.getLatestOverview(
|
|
111
|
+
const a2 = await registry.getLatestOverview(cSpec.id, AnyChannel);
|
|
96
112
|
if (a2 === undefined) {
|
|
97
|
-
this.logger.error(`No "any" channel record for ${blockPackIdToString(
|
|
98
|
-
return
|
|
113
|
+
this.logger.error(`No "any" channel record for ${blockPackIdToString(cSpec.id)}`);
|
|
114
|
+
return { suggestions: [] };
|
|
99
115
|
}
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
const targetChannel = this.preferredUpdateChannel ?? req.channel;
|
|
104
|
-
const a1 = await registry.getLatestOverview(req.id, targetChannel);
|
|
105
|
-
if (a1) spec = a1.spec;
|
|
106
|
-
else {
|
|
107
|
-
this.logger.error(
|
|
108
|
-
`Can't find update for ${blockPackIdToString(req.id)} in channel "${targetChannel}"`
|
|
109
|
-
);
|
|
110
|
-
return undefined;
|
|
116
|
+
channel = AnyChannel;
|
|
111
117
|
}
|
|
118
|
+
} else channel = cSpec.channel;
|
|
119
|
+
|
|
120
|
+
const vSuggestions = await registry.getUpdateSuggestions(cSpec.id, channel);
|
|
121
|
+
if (vSuggestions === undefined || vSuggestions.length === 0) return { suggestions: [] };
|
|
122
|
+
|
|
123
|
+
// from major to patch
|
|
124
|
+
vSuggestions.reverse();
|
|
125
|
+
|
|
126
|
+
let vMainSuggestion: string | undefined = undefined;
|
|
127
|
+
switch (versionLock) {
|
|
128
|
+
case undefined:
|
|
129
|
+
vMainSuggestion = vSuggestions[0].update;
|
|
130
|
+
break;
|
|
131
|
+
case 'major':
|
|
132
|
+
vMainSuggestion = vSuggestions.find((v) => v.type !== 'major')?.update;
|
|
133
|
+
break;
|
|
134
|
+
case 'minor':
|
|
135
|
+
vMainSuggestion = vSuggestions.find((v) => v.type === 'patch')?.update;
|
|
136
|
+
break;
|
|
112
137
|
}
|
|
113
138
|
|
|
114
|
-
|
|
139
|
+
const suggestions: UpdateSuggestions = vSuggestions.map(({ type, update }) => ({
|
|
140
|
+
type,
|
|
141
|
+
update: { ...cSpec, id: { ...cSpec.id, version: update } }
|
|
142
|
+
}));
|
|
115
143
|
|
|
116
|
-
|
|
117
|
-
if (semver.
|
|
144
|
+
if (vMainSuggestion === undefined) return { suggestions };
|
|
145
|
+
if (skipVersion !== undefined && semver.lte(vMainSuggestion, skipVersion))
|
|
146
|
+
return { suggestions };
|
|
147
|
+
|
|
148
|
+
const mainSuggestion: BlockPackFromRegistryV2 = {
|
|
149
|
+
...cSpec,
|
|
150
|
+
id: { ...cSpec.id, version: vMainSuggestion }
|
|
151
|
+
};
|
|
118
152
|
|
|
119
153
|
// warming cache
|
|
120
154
|
// noinspection ES6MissingAwait
|
|
121
155
|
(async () => {
|
|
122
156
|
try {
|
|
123
|
-
await registry.getComponents(
|
|
157
|
+
await registry.getComponents(mainSuggestion.id);
|
|
124
158
|
} catch (e: unknown) {
|
|
125
159
|
this.logger.warn(e);
|
|
126
160
|
}
|
|
127
161
|
})();
|
|
128
162
|
|
|
129
|
-
return
|
|
163
|
+
return { suggestions, mainSuggestion };
|
|
130
164
|
} catch (err: unknown) {
|
|
131
165
|
this.logger.warn(err);
|
|
132
|
-
return
|
|
166
|
+
return { suggestions: [] };
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
169
|
|
|
136
170
|
default:
|
|
137
|
-
return
|
|
171
|
+
return { suggestions: [] };
|
|
138
172
|
}
|
|
139
173
|
} catch (e: unknown) {
|
|
140
174
|
this.logger.warn(e);
|
|
141
|
-
return
|
|
175
|
+
return { suggestions: [] };
|
|
142
176
|
}
|
|
143
177
|
}
|
|
144
178
|
|
|
145
|
-
protected resultsEqual(
|
|
146
|
-
res1
|
|
147
|
-
res2
|
|
148
|
-
|
|
149
|
-
if (res1
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
assertNever(res1);
|
|
167
|
-
}
|
|
179
|
+
protected resultsEqual(res1: CheckForUpdateResponse, res2: CheckForUpdateResponse): boolean {
|
|
180
|
+
return canonicalize(res1) === canonicalize(res2);
|
|
181
|
+
// if (res1 === undefined && res2 === undefined) return true;
|
|
182
|
+
// if (res1 === undefined || res2 === undefined) return false;
|
|
183
|
+
// if (res1.type !== res2.type) return false;
|
|
184
|
+
// switch (res1.type) {
|
|
185
|
+
// case 'from-registry-v1':
|
|
186
|
+
// if (res2.type !== 'from-registry-v1') return false;
|
|
187
|
+
// return res1.registryUrl === res2.registryUrl && blockPackIdEquals(res1.id, res2.id);
|
|
188
|
+
// case 'from-registry-v2':
|
|
189
|
+
// if (res2.type !== 'from-registry-v2') return false;
|
|
190
|
+
// return res1.registryUrl === res2.registryUrl && blockPackIdEquals(res1.id, res2.id);
|
|
191
|
+
// case 'dev-v1':
|
|
192
|
+
// if (res2.type !== 'dev-v1') return false;
|
|
193
|
+
// return res1.folder === res2.folder && res1.mtime === res2.mtime;
|
|
194
|
+
// case 'dev-v2':
|
|
195
|
+
// if (res2.type !== 'dev-v2') return false;
|
|
196
|
+
// return res1.folder === res2.folder && res1.mtime === res2.mtime;
|
|
197
|
+
// default:
|
|
198
|
+
// assertNever(res1);
|
|
199
|
+
// }
|
|
168
200
|
}
|
|
169
201
|
}
|
|
@@ -25,7 +25,8 @@ import { BlockPackInfo } from '../model/block_pack';
|
|
|
25
25
|
import {
|
|
26
26
|
ProjectOverview,
|
|
27
27
|
AuthorMarker,
|
|
28
|
-
BlockStateInternal
|
|
28
|
+
BlockStateInternal,
|
|
29
|
+
BlockSettings
|
|
29
30
|
} from '@milaboratories/pl-model-middle-layer';
|
|
30
31
|
import { activeConfigs } from './active_cfg';
|
|
31
32
|
import { NavigationStates } from './navigation_states';
|
|
@@ -271,6 +272,14 @@ export class Project {
|
|
|
271
272
|
await this.projectTree.refreshState();
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
/** Update block settings */
|
|
276
|
+
public async setBlockSettings(blockId: string, newValue: BlockSettings) {
|
|
277
|
+
await withProjectAuthored(this.env.pl, this.rid, undefined, (mut) => {
|
|
278
|
+
mut.setBlockSettings(blockId, newValue);
|
|
279
|
+
});
|
|
280
|
+
await this.projectTree.refreshState();
|
|
281
|
+
}
|
|
282
|
+
|
|
274
283
|
/** Resets arguments and ui state of the block to initial state */
|
|
275
284
|
public async resetBlockArgsAndUiState(blockId: string, author?: AuthorMarker): Promise<void> {
|
|
276
285
|
await this.env.pl.withWriteTx('BlockInputsReset', async (tx) => {
|
|
@@ -17,6 +17,8 @@ import { MiddleLayerEnvironment } from './middle_layer';
|
|
|
17
17
|
import {
|
|
18
18
|
AuthorMarker,
|
|
19
19
|
BlockCalculationStatus,
|
|
20
|
+
BlockSettings,
|
|
21
|
+
BlockStateOverview,
|
|
20
22
|
ProjectMeta,
|
|
21
23
|
ProjectOverview
|
|
22
24
|
} from '@milaboratories/pl-model-middle-layer';
|
|
@@ -165,8 +167,16 @@ export function projectOverview(
|
|
|
165
167
|
};
|
|
166
168
|
}) || {};
|
|
167
169
|
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
+
const settings = prj
|
|
171
|
+
.traverse({
|
|
172
|
+
field: projectFieldName(id, 'blockSettings'),
|
|
173
|
+
assertFieldType: 'Dynamic',
|
|
174
|
+
errorIfFieldNotSet: true
|
|
175
|
+
})
|
|
176
|
+
.getDataAsJson() as BlockSettings;
|
|
177
|
+
|
|
178
|
+
const updates = ifNotUndef(bp, ({ info }) =>
|
|
179
|
+
env.blockUpdateWatcher.get({ currentSpec: info.source, settings })
|
|
170
180
|
);
|
|
171
181
|
|
|
172
182
|
return {
|
|
@@ -182,10 +192,12 @@ export function projectOverview(
|
|
|
182
192
|
outputErrors: info.prod?.outputError === true,
|
|
183
193
|
outputsError: info.prod?.outputsError,
|
|
184
194
|
exportsError: info.prod?.exportsError,
|
|
195
|
+
settings,
|
|
185
196
|
sections,
|
|
186
197
|
inputsValid,
|
|
198
|
+
updateInfo: {},
|
|
187
199
|
currentBlockPack: bp?.info?.source,
|
|
188
|
-
|
|
200
|
+
updates,
|
|
189
201
|
sdkVersion,
|
|
190
202
|
navigationState: navigationStates.getState(id)
|
|
191
203
|
};
|
|
@@ -214,7 +226,15 @@ export function projectOverview(
|
|
|
214
226
|
Boolean(b.inputsValid) &&
|
|
215
227
|
!b.missingReference &&
|
|
216
228
|
b.upstreams.findIndex((u) => cantRun.has(u)) === -1;
|
|
217
|
-
|
|
229
|
+
const bb = {
|
|
230
|
+
...b,
|
|
231
|
+
canRun,
|
|
232
|
+
stale,
|
|
233
|
+
updateSuggestions: b.updates?.suggestions ?? [],
|
|
234
|
+
updatedBlockPack: b.updates?.mainSuggestion
|
|
235
|
+
};
|
|
236
|
+
delete bb['updates'];
|
|
237
|
+
return bb;
|
|
218
238
|
})
|
|
219
239
|
};
|
|
220
240
|
}
|
|
@@ -15,7 +15,7 @@ export interface Block {
|
|
|
15
15
|
/** Unique block id */
|
|
16
16
|
readonly id: string;
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
19
|
* Label shown to the user
|
|
20
20
|
* @deprecated
|
|
21
21
|
* */
|
|
@@ -114,6 +114,7 @@ export interface ProjectField {
|
|
|
114
114
|
blockId: string;
|
|
115
115
|
fieldName:
|
|
116
116
|
| 'blockPack'
|
|
117
|
+
| 'blockSettings'
|
|
117
118
|
| 'prodArgs'
|
|
118
119
|
| 'currentArgs'
|
|
119
120
|
| 'prodCtx'
|
|
@@ -135,7 +136,7 @@ export function projectFieldName(blockId: string, fieldName: ProjectField['field
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
const projectFieldPattern =
|
|
138
|
-
/^(?<blockId>.*)-(?<fieldName>blockPack|prodArgs|currentArgs|prodCtx|prodUiCtx|prodOutput|prodCtxPrevious|prodUiCtxPrevious|prodOutputPrevious|stagingCtx|stagingUiCtx|stagingOutput|stagingCtxPrevious|stagingUiCtxPrevious|stagingOutputPrevious)$/;
|
|
139
|
+
/^(?<blockId>.*)-(?<fieldName>blockPack|blockSettings|prodArgs|currentArgs|prodCtx|prodUiCtx|prodOutput|prodCtxPrevious|prodUiCtxPrevious|prodOutputPrevious|stagingCtx|stagingUiCtx|stagingOutput|stagingCtxPrevious|stagingUiCtxPrevious|stagingOutputPrevious)$/;
|
|
139
140
|
|
|
140
141
|
export function parseProjectField(name: string): ProjectField | undefined {
|
|
141
142
|
const match = name.match(projectFieldPattern);
|
package/src/mutator/project.ts
CHANGED
|
@@ -49,7 +49,12 @@ import {
|
|
|
49
49
|
} from '../model/project_model_util';
|
|
50
50
|
import { BlockPackSpecPrepared } from '../model';
|
|
51
51
|
import { notEmpty } from '@milaboratories/ts-helpers';
|
|
52
|
-
import {
|
|
52
|
+
import {
|
|
53
|
+
AuthorMarker,
|
|
54
|
+
BlockSettings,
|
|
55
|
+
InitialBlockSettings,
|
|
56
|
+
ProjectMeta
|
|
57
|
+
} from '@milaboratories/pl-model-middle-layer';
|
|
53
58
|
import Denque from 'denque';
|
|
54
59
|
import { exportContext, getPreparedExportTemplateEnvelope } from './context_export';
|
|
55
60
|
import { loadTemplate } from './template/template_loading';
|
|
@@ -64,6 +69,7 @@ interface BlockFieldState {
|
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
type BlockFieldStates = Partial<Record<ProjectField['fieldName'], BlockFieldState>>;
|
|
72
|
+
type BlockFieldStateValue = Omit<BlockFieldState, 'modCount'>;
|
|
67
73
|
|
|
68
74
|
interface BlockInfoState {
|
|
69
75
|
readonly id: string;
|
|
@@ -234,7 +240,8 @@ export class ProjectMutator {
|
|
|
234
240
|
private readonly ctxExportTplHolder: AnyResourceRef
|
|
235
241
|
) {}
|
|
236
242
|
|
|
237
|
-
private
|
|
243
|
+
private fixProblemsAndMigrate() {
|
|
244
|
+
// Fixing problems introduced by old code
|
|
238
245
|
this.blockInfos.forEach((blockInfo) => {
|
|
239
246
|
if (
|
|
240
247
|
blockInfo.fields.prodArgs === undefined ||
|
|
@@ -243,6 +250,16 @@ export class ProjectMutator {
|
|
|
243
250
|
)
|
|
244
251
|
this.deleteBlockFields(blockInfo.id, 'prodArgs', 'prodOutput', 'prodCtx');
|
|
245
252
|
});
|
|
253
|
+
|
|
254
|
+
// Migration for addition of block settings field
|
|
255
|
+
let initialBlockSettings: Omit<BlockFieldState, 'modCount'> | undefined;
|
|
256
|
+
this.blockInfos.forEach((blockInfo) => {
|
|
257
|
+
if (blockInfo.fields.blockSettings === undefined) {
|
|
258
|
+
if (initialBlockSettings === undefined)
|
|
259
|
+
initialBlockSettings = this.createJsonFieldValue(InitialBlockSettings);
|
|
260
|
+
this.setBlockFieldObj(blockInfo.id, 'blockSettings', initialBlockSettings);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
246
263
|
}
|
|
247
264
|
|
|
248
265
|
get wasModified(): boolean {
|
|
@@ -297,7 +314,19 @@ export class ProjectMutator {
|
|
|
297
314
|
//
|
|
298
315
|
|
|
299
316
|
private getBlockInfo(blockId: string): BlockInfo {
|
|
300
|
-
|
|
317
|
+
const info = this.blockInfos.get(blockId);
|
|
318
|
+
if (info === undefined) throw new Error(`No such block: ${blockId}`);
|
|
319
|
+
return info;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private createJsonFieldValueByContent(content: string): BlockFieldStateValue {
|
|
323
|
+
const value = Buffer.from(content);
|
|
324
|
+
const ref = this.tx.createValue(Pl.JsonObject, value);
|
|
325
|
+
return { ref, value, status: 'Ready' };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private createJsonFieldValue(obj: unknown): BlockFieldStateValue {
|
|
329
|
+
return this.createJsonFieldValueByContent(JSON.stringify(obj));
|
|
301
330
|
}
|
|
302
331
|
|
|
303
332
|
private getBlock(blockId: string): Block {
|
|
@@ -308,7 +337,7 @@ export class ProjectMutator {
|
|
|
308
337
|
private setBlockFieldObj(
|
|
309
338
|
blockId: string,
|
|
310
339
|
fieldName: keyof BlockFieldStates,
|
|
311
|
-
state:
|
|
340
|
+
state: BlockFieldStateValue
|
|
312
341
|
) {
|
|
313
342
|
const fid = field(this.rid, projectFieldName(blockId, fieldName));
|
|
314
343
|
|
|
@@ -447,6 +476,11 @@ export class ProjectMutator {
|
|
|
447
476
|
this.updateLastModified();
|
|
448
477
|
}
|
|
449
478
|
|
|
479
|
+
public setBlockSettings(blockId: string, newValue: BlockSettings): void {
|
|
480
|
+
this.setBlockFieldObj(blockId, 'blockSettings', this.createJsonFieldValue(newValue));
|
|
481
|
+
this.updateLastModified();
|
|
482
|
+
}
|
|
483
|
+
|
|
450
484
|
/** Update block label */
|
|
451
485
|
// public setBlockLabel(blockId: string, label: string): void {
|
|
452
486
|
// const newStructure = this.structure;
|
|
@@ -586,10 +620,15 @@ export class ProjectMutator {
|
|
|
586
620
|
const bp = createBlockPack(this.tx, spec.blockPack);
|
|
587
621
|
this.setBlockField(blockId, 'blockPack', Pl.wrapInHolder(this.tx, bp), 'NotReady');
|
|
588
622
|
|
|
623
|
+
// settings
|
|
624
|
+
this.setBlockFieldObj(
|
|
625
|
+
blockId,
|
|
626
|
+
'blockSettings',
|
|
627
|
+
this.createJsonFieldValue(InitialBlockSettings)
|
|
628
|
+
);
|
|
629
|
+
|
|
589
630
|
// args
|
|
590
|
-
|
|
591
|
-
const argsRes = this.tx.createValue(Pl.JsonObject, binArgs);
|
|
592
|
-
this.setBlockField(blockId, 'currentArgs', argsRes, 'Ready', binArgs);
|
|
631
|
+
this.setBlockFieldObj(blockId, 'currentArgs', this.createJsonFieldValueByContent(spec.args));
|
|
593
632
|
|
|
594
633
|
// uiState
|
|
595
634
|
if (spec.uiState /* this check is for compatibility with old configs */) {
|
|
@@ -1052,7 +1091,7 @@ export class ProjectMutator {
|
|
|
1052
1091
|
ctxExportTplHolder
|
|
1053
1092
|
);
|
|
1054
1093
|
|
|
1055
|
-
prj.
|
|
1094
|
+
prj.fixProblemsAndMigrate();
|
|
1056
1095
|
|
|
1057
1096
|
return prj;
|
|
1058
1097
|
}
|