@milaboratories/pl-model-middle-layer 1.2.16
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.cjs +249 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
- package/src/author_marker.ts +10 -0
- package/src/block_meta/block_components.ts +47 -0
- package/src/block_meta/block_pack_id.ts +15 -0
- package/src/block_meta/common.ts +2 -0
- package/src/block_meta/content_conversion.ts +13 -0
- package/src/block_meta/content_types.ts +233 -0
- package/src/block_meta/index.ts +51 -0
- package/src/block_meta/meta.ts +54 -0
- package/src/block_meta/semver.ts +10 -0
- package/src/block_pack.ts +29 -0
- package/src/block_state.ts +14 -0
- package/src/index.ts +8 -0
- package/src/pframe/index.ts +1 -0
- package/src/pframe/internal_api/api_factory.ts +68 -0
- package/src/pframe/internal_api/api_read.ts +39 -0
- package/src/pframe/internal_api/common.ts +22 -0
- package/src/pframe/internal_api/create_table.ts +31 -0
- package/src/pframe/internal_api/delete_column.ts +12 -0
- package/src/pframe/internal_api/find_columns.ts +27 -0
- package/src/pframe/internal_api/index.ts +9 -0
- package/src/pframe/internal_api/pframe.ts +4 -0
- package/src/pframe/internal_api/table.ts +49 -0
- package/src/project.ts +4 -0
- package/src/project_list.ts +19 -0
- package/src/project_overview.ts +126 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContentAbsoluteUrl, ContentAnyLocal, ContentRelative } from "./content_types";
|
|
2
|
+
|
|
3
|
+
export function mapRemoteToAbsolute(
|
|
4
|
+
rootUrl: string
|
|
5
|
+
): <T extends ContentAnyLocal>(
|
|
6
|
+
value: T
|
|
7
|
+
) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {
|
|
8
|
+
const rootWithSlash = rootUrl.endsWith('/') ? rootUrl : `${rootUrl}/`;
|
|
9
|
+
return <T extends ContentAnyLocal>(value: T) =>
|
|
10
|
+
value.type === 'relative'
|
|
11
|
+
? { type: 'absolute-url', url: rootWithSlash + value.path }
|
|
12
|
+
: (value as Exclude<T, ContentRelative>);
|
|
13
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
// Base content types
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const ContentExplicitString = z
|
|
8
|
+
.object({
|
|
9
|
+
type: z.literal('explicit-string'),
|
|
10
|
+
content: z.string().describe('Actual string value')
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export type ContentExplicitString = z.infer<typeof ContentExplicitString>;
|
|
14
|
+
|
|
15
|
+
export const ContentExplicitBase64 = z
|
|
16
|
+
.object({
|
|
17
|
+
type: z.literal('explicit-base64'),
|
|
18
|
+
mimeType: z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(/\w+\/[-+.\w]+/)
|
|
21
|
+
.describe('MIME type to interpret content'),
|
|
22
|
+
content: z.string().base64().describe('Base64 encoded binary value')
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
export type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;
|
|
26
|
+
|
|
27
|
+
export const ContentRelative = z
|
|
28
|
+
.object({
|
|
29
|
+
type: z.literal('relative'),
|
|
30
|
+
path: z
|
|
31
|
+
.string()
|
|
32
|
+
.describe(
|
|
33
|
+
'Address of the file, in most cases relative to the file which this structure is a part of'
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export type ContentRelative = z.infer<typeof ContentRelative>;
|
|
38
|
+
|
|
39
|
+
export const ContentAbsoluteFile = z
|
|
40
|
+
.object({
|
|
41
|
+
type: z.literal('absolute-file'),
|
|
42
|
+
file: z.string().startsWith('/').describe('Absolute address of the file in local file system')
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
export type ContentAbsoluteFile = z.infer<typeof ContentAbsoluteFile>;
|
|
46
|
+
|
|
47
|
+
export const ContentAbsoluteUrl = z
|
|
48
|
+
.object({
|
|
49
|
+
type: z.literal('absolute-url'),
|
|
50
|
+
url: z.string().url().describe('Global URL to reach the requested file')
|
|
51
|
+
})
|
|
52
|
+
.strict();
|
|
53
|
+
export type ContentAbsoluteUrl = z.infer<typeof ContentAbsoluteUrl>;
|
|
54
|
+
|
|
55
|
+
//
|
|
56
|
+
// Special content types
|
|
57
|
+
//
|
|
58
|
+
|
|
59
|
+
export const ContentExplicit = z
|
|
60
|
+
.object({
|
|
61
|
+
type: z.literal('explicit'),
|
|
62
|
+
content: z.instanceof(Uint8Array).describe('Raw content')
|
|
63
|
+
})
|
|
64
|
+
.strict();
|
|
65
|
+
export type ContentExplicit = z.infer<typeof ContentExplicit>;
|
|
66
|
+
|
|
67
|
+
export const ContentAbsoluteFolder = z
|
|
68
|
+
.object({
|
|
69
|
+
type: z.literal('absolute-folder'),
|
|
70
|
+
folder: z
|
|
71
|
+
.string()
|
|
72
|
+
.startsWith('/')
|
|
73
|
+
.describe('Absolute address of the folder in local file system')
|
|
74
|
+
})
|
|
75
|
+
.strict();
|
|
76
|
+
export type ContentAbsoluteFolder = z.infer<typeof ContentAbsoluteFolder>;
|
|
77
|
+
|
|
78
|
+
//
|
|
79
|
+
// Unions
|
|
80
|
+
//
|
|
81
|
+
|
|
82
|
+
export const ContentAny = z.discriminatedUnion('type', [
|
|
83
|
+
ContentExplicitString,
|
|
84
|
+
ContentExplicitBase64,
|
|
85
|
+
ContentRelative,
|
|
86
|
+
ContentAbsoluteFile,
|
|
87
|
+
ContentAbsoluteUrl
|
|
88
|
+
]);
|
|
89
|
+
export type ContentAny = z.infer<typeof ContentAny>;
|
|
90
|
+
|
|
91
|
+
export const ContentAnyLocal = z.discriminatedUnion('type', [
|
|
92
|
+
ContentExplicitString,
|
|
93
|
+
ContentExplicitBase64,
|
|
94
|
+
ContentRelative,
|
|
95
|
+
ContentAbsoluteFile
|
|
96
|
+
]);
|
|
97
|
+
export type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;
|
|
98
|
+
|
|
99
|
+
export const ContentAnyRemote = z.discriminatedUnion('type', [
|
|
100
|
+
ContentExplicitString,
|
|
101
|
+
ContentExplicitBase64,
|
|
102
|
+
ContentRelative,
|
|
103
|
+
ContentAbsoluteUrl
|
|
104
|
+
]);
|
|
105
|
+
export type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;
|
|
106
|
+
|
|
107
|
+
//
|
|
108
|
+
// Narrow types with relative option
|
|
109
|
+
//
|
|
110
|
+
|
|
111
|
+
// export const ContentAnyBinaryRemote = z.discriminatedUnion('type', [
|
|
112
|
+
// ContentExplicitBase64,
|
|
113
|
+
// ContentRelative,
|
|
114
|
+
// ContentAbsoluteUrl
|
|
115
|
+
// ]);
|
|
116
|
+
// export type ContentAnyBinaryRemote = z.infer<typeof ContentAnyBinaryRemote>;
|
|
117
|
+
|
|
118
|
+
export const ContentAnyBinaryLocal = z.discriminatedUnion('type', [
|
|
119
|
+
ContentExplicitBase64,
|
|
120
|
+
ContentRelative,
|
|
121
|
+
ContentAbsoluteFile
|
|
122
|
+
]);
|
|
123
|
+
export type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;
|
|
124
|
+
|
|
125
|
+
// export const ContentAnyTextRemote = z.discriminatedUnion('type', [
|
|
126
|
+
// ContentExplicitString,
|
|
127
|
+
// ContentRelative,
|
|
128
|
+
// ContentAbsoluteUrl
|
|
129
|
+
// ]);
|
|
130
|
+
// export type ContentAnyTextRemote = z.infer<typeof ContentAnyTextRemote>;
|
|
131
|
+
|
|
132
|
+
export const ContentAnyTextLocal = z.discriminatedUnion('type', [
|
|
133
|
+
ContentExplicitString,
|
|
134
|
+
ContentRelative,
|
|
135
|
+
ContentAbsoluteFile
|
|
136
|
+
]);
|
|
137
|
+
export type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;
|
|
138
|
+
|
|
139
|
+
//
|
|
140
|
+
// Narrow absolute types
|
|
141
|
+
//
|
|
142
|
+
|
|
143
|
+
export const ContentAbsoluteBinaryRemote = z.discriminatedUnion('type', [
|
|
144
|
+
ContentExplicitBase64,
|
|
145
|
+
ContentAbsoluteUrl
|
|
146
|
+
]);
|
|
147
|
+
export type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;
|
|
148
|
+
|
|
149
|
+
export const ContentAbsoluteBinaryLocal = z.discriminatedUnion('type', [
|
|
150
|
+
ContentExplicitBase64,
|
|
151
|
+
ContentAbsoluteFile
|
|
152
|
+
]);
|
|
153
|
+
export type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;
|
|
154
|
+
|
|
155
|
+
export const ContentAbsoluteTextRemote = z.discriminatedUnion('type', [
|
|
156
|
+
ContentExplicitString,
|
|
157
|
+
ContentAbsoluteUrl
|
|
158
|
+
]);
|
|
159
|
+
export type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;
|
|
160
|
+
|
|
161
|
+
export const ContentAbsoluteTextLocal = z.discriminatedUnion('type', [
|
|
162
|
+
ContentExplicitString,
|
|
163
|
+
ContentAbsoluteFile
|
|
164
|
+
]);
|
|
165
|
+
export type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;
|
|
166
|
+
|
|
167
|
+
//
|
|
168
|
+
// Narrow relative types
|
|
169
|
+
//
|
|
170
|
+
|
|
171
|
+
export const ContentRelativeBinary = z.discriminatedUnion('type', [
|
|
172
|
+
ContentExplicitBase64,
|
|
173
|
+
ContentRelative
|
|
174
|
+
]);
|
|
175
|
+
export type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;
|
|
176
|
+
|
|
177
|
+
export const ContentRelativeText = z.discriminatedUnion('type', [
|
|
178
|
+
ContentExplicitString,
|
|
179
|
+
ContentRelative
|
|
180
|
+
]);
|
|
181
|
+
export type ContentRelativeText = z.infer<typeof ContentRelativeText>;
|
|
182
|
+
|
|
183
|
+
// export function ConstructContent(
|
|
184
|
+
// contentType: 'text',
|
|
185
|
+
// contextType: 'local'
|
|
186
|
+
// ): typeof ContentAnyTextLocal;
|
|
187
|
+
// export function ConstructContent(
|
|
188
|
+
// contentType: 'text',
|
|
189
|
+
// contextType: 'remote'
|
|
190
|
+
// ): typeof ContentAnyTextRemote;
|
|
191
|
+
// export function ConstructContent(
|
|
192
|
+
// contentType: 'binary',
|
|
193
|
+
// contextType: 'local'
|
|
194
|
+
// ): typeof ContentAnyBinaryLocal;
|
|
195
|
+
// export function ConstructContent(
|
|
196
|
+
// contentType: 'binary',
|
|
197
|
+
// contextType: 'remote'
|
|
198
|
+
// ): typeof ContentAnyBinaryRemote;
|
|
199
|
+
// export function ConstructContent(
|
|
200
|
+
// contentType: ContentType,
|
|
201
|
+
// contextType: ContextType
|
|
202
|
+
// ):
|
|
203
|
+
// | typeof ContentAnyTextLocal
|
|
204
|
+
// | typeof ContentAnyTextRemote
|
|
205
|
+
// | typeof ContentAnyBinaryLocal
|
|
206
|
+
// | typeof ContentAnyBinaryRemote;
|
|
207
|
+
// export function ConstructContent(contentType: ContentType, contextType: ContextType) {
|
|
208
|
+
// return contentType === 'text'
|
|
209
|
+
// ? contextType === 'local'
|
|
210
|
+
// ? ContentAnyTextLocal
|
|
211
|
+
// : ContentAnyTextRemote
|
|
212
|
+
// : contextType === 'local'
|
|
213
|
+
// ? ContentAnyBinaryLocal
|
|
214
|
+
// : ContentAnyBinaryRemote;
|
|
215
|
+
// }
|
|
216
|
+
|
|
217
|
+
export const DescriptionContentBinary = z.union([
|
|
218
|
+
z
|
|
219
|
+
.string()
|
|
220
|
+
.startsWith('file:')
|
|
221
|
+
.transform<ContentRelativeBinary>((value, ctx) => ({ type: 'relative', path: value.slice(5) })),
|
|
222
|
+
ContentAnyBinaryLocal
|
|
223
|
+
]);
|
|
224
|
+
export type DescriptionContentBinary = z.infer<typeof DescriptionContentBinary>;
|
|
225
|
+
|
|
226
|
+
export const DescriptionContentText = z.union([
|
|
227
|
+
z.string().transform<ContentRelativeText>((value, ctx) => {
|
|
228
|
+
if (value.startsWith('file:')) return { type: 'relative', path: value.slice(5) };
|
|
229
|
+
else return { type: 'explicit-string', content: value };
|
|
230
|
+
}),
|
|
231
|
+
ContentAnyTextLocal
|
|
232
|
+
]);
|
|
233
|
+
export type DescriptionContentText = z.infer<typeof DescriptionContentText>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ZodTypeAny, z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
BlockComponentsDescriptionRaw,
|
|
4
|
+
BlockComponentsManifest
|
|
5
|
+
} from './block_components';
|
|
6
|
+
import { BlockPackId } from './block_pack_id';
|
|
7
|
+
import {
|
|
8
|
+
BlockPackMetaDescriptionRaw,
|
|
9
|
+
BlockPackMetaManifest
|
|
10
|
+
} from './meta';
|
|
11
|
+
|
|
12
|
+
export * from './block_components'
|
|
13
|
+
export * from './block_pack_id'
|
|
14
|
+
export * from './common'
|
|
15
|
+
export * from './content_types'
|
|
16
|
+
export * from './meta'
|
|
17
|
+
export * from './semver'
|
|
18
|
+
|
|
19
|
+
export const BlockPackDescriptionFromPackageJsonRaw = z.object({
|
|
20
|
+
components: BlockComponentsDescriptionRaw,
|
|
21
|
+
meta: BlockPackMetaDescriptionRaw
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export function CreateBlockPackDescriptionSchema<Components extends ZodTypeAny, Meta extends ZodTypeAny>(
|
|
25
|
+
components: Components,
|
|
26
|
+
meta: Meta
|
|
27
|
+
) {
|
|
28
|
+
return z.object({
|
|
29
|
+
id: BlockPackId,
|
|
30
|
+
components,
|
|
31
|
+
meta
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
|
|
36
|
+
BlockComponentsManifest,
|
|
37
|
+
BlockPackMetaManifest
|
|
38
|
+
);
|
|
39
|
+
export type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;
|
|
40
|
+
|
|
41
|
+
export const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(
|
|
42
|
+
BlockComponentsDescriptionRaw,
|
|
43
|
+
BlockPackMetaDescriptionRaw
|
|
44
|
+
);
|
|
45
|
+
export type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;
|
|
46
|
+
|
|
47
|
+
export const BlockPackManifest = BlockPackDescriptionManifest.extend({
|
|
48
|
+
schema: z.literal('v1'),
|
|
49
|
+
files: z.array(z.string())
|
|
50
|
+
});
|
|
51
|
+
export type BlockPackManifest = z.infer<typeof BlockPackManifest>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
ContentAbsoluteBinaryLocal,
|
|
4
|
+
ContentAbsoluteTextLocal,
|
|
5
|
+
ContentExplicitBase64,
|
|
6
|
+
ContentExplicitString,
|
|
7
|
+
ContentRelative,
|
|
8
|
+
ContentRelativeBinary,
|
|
9
|
+
ContentRelativeText,
|
|
10
|
+
DescriptionContentBinary,
|
|
11
|
+
DescriptionContentText
|
|
12
|
+
} from './content_types';
|
|
13
|
+
|
|
14
|
+
export function BlockPackMeta<
|
|
15
|
+
const LongStringType extends z.ZodTypeAny,
|
|
16
|
+
const BinaryType extends z.ZodTypeAny
|
|
17
|
+
>(longString: LongStringType, binary: BinaryType) {
|
|
18
|
+
return z.object({
|
|
19
|
+
title: z.string(),
|
|
20
|
+
description: z.string(),
|
|
21
|
+
longDescription: longString.optional(),
|
|
22
|
+
logo: binary.optional(),
|
|
23
|
+
url: z.string().url().optional(),
|
|
24
|
+
docs: z.string().url().optional(),
|
|
25
|
+
support: z.union([z.string().url(), z.string().email()]).optional(),
|
|
26
|
+
tags: z.array(z.string()).optional(),
|
|
27
|
+
organization: z.object({
|
|
28
|
+
name: z.string(),
|
|
29
|
+
url: z.string().url(),
|
|
30
|
+
logo: binary.optional()
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// prettier-ignore
|
|
36
|
+
export const BlockPackMetaDescriptionRaw = BlockPackMeta(
|
|
37
|
+
DescriptionContentText,
|
|
38
|
+
DescriptionContentBinary
|
|
39
|
+
);
|
|
40
|
+
export type BlockPackMetaDescriptionRaw = z.infer<typeof BlockPackMetaDescriptionRaw>;
|
|
41
|
+
|
|
42
|
+
// prettier-ignore
|
|
43
|
+
export const BlockPackMetaManifest = BlockPackMeta(
|
|
44
|
+
ContentRelativeText,
|
|
45
|
+
ContentRelativeBinary
|
|
46
|
+
);
|
|
47
|
+
export type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;
|
|
48
|
+
|
|
49
|
+
// prettier-ignore
|
|
50
|
+
export const BlockPackMetaEmbeddedContent = BlockPackMeta(
|
|
51
|
+
z.string(),
|
|
52
|
+
ContentExplicitBase64
|
|
53
|
+
);
|
|
54
|
+
export type BlockPackMetaEmbeddedContent = z.infer<typeof BlockPackMetaEmbeddedContent>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Regex taken from here:
|
|
4
|
+
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
|
5
|
+
export const SemVer = z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(
|
|
8
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,
|
|
9
|
+
'Wrong version format, please use valid semver'
|
|
10
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Block pack from local folder, to be used during block development. Legacy layout. */
|
|
2
|
+
export interface BlockPackDevV1 {
|
|
3
|
+
type: 'dev' | 'dev-v1';
|
|
4
|
+
folder: string;
|
|
5
|
+
mtime?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Block pack from local folder, to be used during block development. New layout. */
|
|
9
|
+
export interface BlockPackDevV2 {
|
|
10
|
+
type: 'dev-v2';
|
|
11
|
+
folder: string;
|
|
12
|
+
mtime?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Block pack from registry with version 1 layout, to be loaded directly
|
|
16
|
+
* from the client. */
|
|
17
|
+
export interface BlockPackFromRegistryV1 {
|
|
18
|
+
type: 'from-registry-v1';
|
|
19
|
+
registryUrl: string;
|
|
20
|
+
organization: string;
|
|
21
|
+
package: string;
|
|
22
|
+
version: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Information about block origin, can be used to instantiate new blocks */
|
|
26
|
+
export type BlockPackSpec =
|
|
27
|
+
| BlockPackDevV1
|
|
28
|
+
| BlockPackDevV2
|
|
29
|
+
| BlockPackFromRegistryV1;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BlockOutputsBase, BlockState } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { AuthorMarker } from './author_marker';
|
|
3
|
+
import { Optional } from 'utility-types';
|
|
4
|
+
|
|
5
|
+
export type BlockStateInternal<
|
|
6
|
+
Args = unknown,
|
|
7
|
+
Outputs extends BlockOutputsBase = BlockOutputsBase,
|
|
8
|
+
UiState = unknown,
|
|
9
|
+
Href extends `/${string}` = `/${string}`
|
|
10
|
+
> = Optional<Readonly<BlockState<Args, Outputs, UiState, Href>>, 'outputs'> & {
|
|
11
|
+
/** Author marker for Args and UI State. Absence of author marker, means that
|
|
12
|
+
* last modifier of the state provided no author marker. */
|
|
13
|
+
readonly author?: AuthorMarker;
|
|
14
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as PFrameInternal from './internal_api';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PColumnSpec, PObjectId } from '@milaboratories/pl-model-common';
|
|
2
|
+
|
|
3
|
+
/** Abstract identifier of a data blob that can be requested from the storage backend */
|
|
4
|
+
export type PFrameBlobId = string;
|
|
5
|
+
|
|
6
|
+
export type JsonDataValue = string | number | null;
|
|
7
|
+
|
|
8
|
+
export type JsonDataInfo = {
|
|
9
|
+
type: 'Json';
|
|
10
|
+
keyLength: number;
|
|
11
|
+
data: Record<string, JsonDataValue>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type JsonPartitionedDataInfo<Blob = PFrameBlobId> = {
|
|
15
|
+
type: 'JsonPartitioned';
|
|
16
|
+
partitionKeyLength: number;
|
|
17
|
+
parts: Record<string, Blob>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type BinaryChunkInfo<Blob = PFrameBlobId> = {
|
|
21
|
+
index: Blob;
|
|
22
|
+
values: Blob;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type BinaryPartitionedDataInfo<Blob = PFrameBlobId> = {
|
|
26
|
+
type: 'BinaryPartitioned';
|
|
27
|
+
partitionKeyLength: number;
|
|
28
|
+
parts: Record<string, BinaryChunkInfo<Blob>>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type DataInfo<Blob = PFrameBlobId> =
|
|
32
|
+
| JsonDataInfo
|
|
33
|
+
| JsonPartitionedDataInfo<Blob>
|
|
34
|
+
| BinaryPartitionedDataInfo<Blob>;
|
|
35
|
+
|
|
36
|
+
/** Path of the file containing requested data (blob). This path is returned by
|
|
37
|
+
* {@link BlobPathResolver} as soon as blob materialized in the file system. */
|
|
38
|
+
export type FilePath = string;
|
|
39
|
+
|
|
40
|
+
/** Data source allows PFrame to retrieve the data blobs for columns with assigned data info. */
|
|
41
|
+
export type PFrameDataSource = {
|
|
42
|
+
/**
|
|
43
|
+
* PFrame may notify storage backend about its plans to use particular blobs in the future.
|
|
44
|
+
* Storage backend will do its best to preload specified blob so the subsequent
|
|
45
|
+
* {@link resolveBlob} will quickly return preloaded file path.
|
|
46
|
+
*/
|
|
47
|
+
preloadBlob(blobIds: PFrameBlobId[]): Promise<void>;
|
|
48
|
+
|
|
49
|
+
/** Allows to read actual data given the blob id from {@link DataInfo}. */
|
|
50
|
+
resolveBlob(blobId: PFrameBlobId): Promise<FilePath>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** API exposed by PFrames library allowing to create and provide data for
|
|
54
|
+
* PFrame objects */
|
|
55
|
+
export interface PFrameFactoryAPI {
|
|
56
|
+
/** Associates data source with this PFrame */
|
|
57
|
+
setDataSource(dataSource: PFrameDataSource): void;
|
|
58
|
+
|
|
59
|
+
/** Adds PColumn without spec */
|
|
60
|
+
addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void;
|
|
61
|
+
|
|
62
|
+
/** Associates data info with cpecific column */
|
|
63
|
+
setColumnData(columnId: PObjectId, dataInfo: DataInfo): void;
|
|
64
|
+
|
|
65
|
+
/** Releases all the data previously added to PFrame using methods above,
|
|
66
|
+
* any interactions with disposed PFrame will result in exception */
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
2
|
+
import { DeleteColumnFromColumnsRequest, DeleteColumnFromColumnsResponse } from './delete_column';
|
|
3
|
+
import {
|
|
4
|
+
PColumnInfo,
|
|
5
|
+
PColumnSpec,
|
|
6
|
+
PObjectId,
|
|
7
|
+
UniqueValuesRequest,
|
|
8
|
+
UniqueValuesResponse
|
|
9
|
+
} from '@milaboratories/pl-model-common';
|
|
10
|
+
import { CreateTableRequest } from './create_table';
|
|
11
|
+
import { PTable } from './table';
|
|
12
|
+
|
|
13
|
+
/** Read interface exposed by PFrames library */
|
|
14
|
+
export interface PFrameReadAPI {
|
|
15
|
+
/**
|
|
16
|
+
* Finds columns given filtering criteria on column name, annotations etc.
|
|
17
|
+
* and a set of qualified axes specs to find only columns with compatible
|
|
18
|
+
* axes spec.
|
|
19
|
+
*
|
|
20
|
+
* Only column specs are used, this method will work even for columns
|
|
21
|
+
* with no assigned data.
|
|
22
|
+
* */
|
|
23
|
+
findColumns(request: FindColumnsRequest): Promise<FindColumnsResponse>;
|
|
24
|
+
|
|
25
|
+
/** To be reviewed in the future */
|
|
26
|
+
deleteColumn(request: DeleteColumnFromColumnsRequest): Promise<DeleteColumnFromColumnsResponse>;
|
|
27
|
+
|
|
28
|
+
/** Retrieve single column spec */
|
|
29
|
+
getColumnSpec(columnId: PObjectId): Promise<PColumnSpec>;
|
|
30
|
+
|
|
31
|
+
/** Retrieve information about all columns currently added to the PFrame */
|
|
32
|
+
listColumns(): Promise<PColumnInfo[]>;
|
|
33
|
+
|
|
34
|
+
/** Calculates data for the table and returns an object to access it */
|
|
35
|
+
createTable(request: CreateTableRequest): Promise<PTable>;
|
|
36
|
+
|
|
37
|
+
/** Calculate set of unique values for a specific axis for the filtered set of records */
|
|
38
|
+
getUniqueValues(request: UniqueValuesRequest): Promise<UniqueValuesResponse>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AxisId, AxisSpec, ValueType } from '@milaboratories/pl-model-common';
|
|
2
|
+
|
|
3
|
+
export interface SingleAxisSelector {
|
|
4
|
+
name: string;
|
|
5
|
+
type?: ValueType;
|
|
6
|
+
domain?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AxisQualification {
|
|
10
|
+
axis: SingleAxisSelector;
|
|
11
|
+
additionalDomains: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AxisQualificationWithAxisId {
|
|
15
|
+
axis: AxisId;
|
|
16
|
+
additionalDomains: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ColumnAxesWithQualifications {
|
|
20
|
+
axesSpec: AxisSpec[];
|
|
21
|
+
qualifications: AxisQualification[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AxisQualificationWithAxisId } from './common';
|
|
2
|
+
import { PObjectId, PTableRecordFilter } from '@milaboratories/pl-model-common';
|
|
3
|
+
|
|
4
|
+
export interface ColumnJoinEntry {
|
|
5
|
+
type: 'column';
|
|
6
|
+
columnId: PObjectId;
|
|
7
|
+
qualifications: AxisQualificationWithAxisId[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface InnerJoin {
|
|
11
|
+
type: 'inner';
|
|
12
|
+
entries: JoinEntry[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FullJoin {
|
|
16
|
+
type: 'full';
|
|
17
|
+
entries: JoinEntry[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface OuterJoin {
|
|
21
|
+
type: 'outer';
|
|
22
|
+
primary: JoinEntry;
|
|
23
|
+
secondary: JoinEntry[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type JoinEntry = ColumnJoinEntry | InnerJoin | FullJoin | OuterJoin;
|
|
27
|
+
|
|
28
|
+
export interface CreateTableRequest {
|
|
29
|
+
src: JoinEntry;
|
|
30
|
+
filters: PTableRecordFilter[];
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ColumnAxesWithQualifications } from './common';
|
|
2
|
+
|
|
3
|
+
export interface DeleteColumnFromColumnsRequest {
|
|
4
|
+
columns: ColumnAxesWithQualifications[];
|
|
5
|
+
|
|
6
|
+
/** Zero based index of the column to delete */
|
|
7
|
+
delete: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DeleteColumnFromColumnsResponse {
|
|
11
|
+
columns: ColumnAxesWithQualifications[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ColumnFilter, PColumnIdAndSpec } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { AxisQualification, ColumnAxesWithQualifications } from './common';
|
|
3
|
+
|
|
4
|
+
export interface FindColumnsRequest {
|
|
5
|
+
columnFilter: ColumnFilter;
|
|
6
|
+
compatibleWith: ColumnAxesWithQualifications[];
|
|
7
|
+
strictlyCompatible: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FindColumnResponseQualifications {
|
|
11
|
+
forQueries: AxisQualification[][];
|
|
12
|
+
forHit: AxisQualification[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FindColumnsMappingVariant {
|
|
16
|
+
qualifications: FindColumnResponseQualifications;
|
|
17
|
+
distinctiveQualifications: FindColumnResponseQualifications;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FindColumnsResponseHit {
|
|
21
|
+
hit: PColumnIdAndSpec;
|
|
22
|
+
mappingVariants: FindColumnsMappingVariant[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface FindColumnsResponse {
|
|
26
|
+
hits: FindColumnsResponseHit[];
|
|
27
|
+
}
|