@milaboratories/pl-model-middle-layer 1.5.12 → 1.6.0

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.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { z as t } from "zod";
2
- const r = t.object({
2
+ import * as v from "remeda";
3
+ const s = t.object({
3
4
  type: t.literal("explicit-string"),
4
5
  content: t.string().describe("Actual string value")
5
- }).strict(), i = t.object({
6
+ }).strict(), r = t.object({
6
7
  type: t.literal("explicit-base64"),
7
8
  mimeType: t.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
8
9
  content: t.string().base64().describe("Base64 encoded binary value")
@@ -11,123 +12,131 @@ const r = t.object({
11
12
  path: t.string().describe(
12
13
  "Address of the file, in most cases relative to the file which this structure is a part of"
13
14
  )
14
- }).strict(), y = new RegExp("^(/|[A-Z]:\\\\)"), c = t.object({
15
+ }).strict(), b = new RegExp("^(/|[A-Z]:\\\\)"), c = t.object({
15
16
  type: t.literal("absolute-file"),
16
- file: t.string().regex(y, "path to file must be absolute").describe("Absolute address of the file in local file system")
17
+ file: t.string().regex(b, "path to file must be absolute").describe("Absolute address of the file in local file system")
17
18
  }).strict(), l = t.object({
18
19
  type: t.literal("absolute-url"),
19
20
  url: t.string().url().describe("Global URL to reach the requested file")
20
- }).strict(), B = t.object({
21
+ }).strict(), A = t.object({
21
22
  type: t.literal("explicit-bytes"),
22
23
  mimeType: t.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
23
24
  content: t.instanceof(Uint8Array).describe("Raw content")
24
- }).strict(), N = t.object({
25
+ }).strict(), Y = t.object({
25
26
  type: t.literal("absolute-folder"),
26
- folder: t.string().regex(y, "path to folder must be absolute").describe("Absolute address of the folder in local file system")
27
- }).strict(), G = t.discriminatedUnion("type", [
27
+ folder: t.string().regex(b, "path to folder must be absolute").describe("Absolute address of the folder in local file system")
28
+ }).strict(), tt = t.discriminatedUnion("type", [
29
+ s,
28
30
  r,
29
- i,
30
31
  o,
31
32
  c,
32
33
  l
33
- ]), J = t.discriminatedUnion("type", [
34
+ ]), et = t.discriminatedUnion("type", [
35
+ s,
34
36
  r,
35
- i,
36
37
  o
37
- ]), H = t.discriminatedUnion("type", [
38
+ ]), nt = t.discriminatedUnion("type", [
39
+ s,
38
40
  r,
39
- i,
40
41
  o,
41
42
  c
42
- ]), K = t.discriminatedUnion("type", [
43
+ ]), it = t.discriminatedUnion("type", [
44
+ s,
43
45
  r,
44
- i,
45
46
  o,
46
47
  l
47
- ]), j = t.discriminatedUnion("type", [
48
- i,
49
- o,
50
- c
51
- ]), P = t.discriminatedUnion("type", [
48
+ ]), x = t.discriminatedUnion("type", [
52
49
  r,
53
50
  o,
54
51
  c
55
- ]), Q = t.discriminatedUnion("type", [
56
- i,
57
- l
58
- ]), X = t.discriminatedUnion("type", [
59
- i,
52
+ ]), w = t.discriminatedUnion("type", [
53
+ s,
54
+ o,
60
55
  c
61
- ]), Y = t.discriminatedUnion("type", [
56
+ ]), ot = t.discriminatedUnion("type", [
62
57
  r,
63
58
  l
64
- ]), tt = t.discriminatedUnion("type", [
59
+ ]), rt = t.discriminatedUnion("type", [
65
60
  r,
66
61
  c
67
- ]), p = t.discriminatedUnion("type", [
68
- i,
69
- o
70
- ]), R = t.discriminatedUnion("type", [
62
+ ]), st = t.discriminatedUnion("type", [
63
+ s,
64
+ l
65
+ ]), ct = t.discriminatedUnion("type", [
66
+ s,
67
+ c
68
+ ]), m = t.discriminatedUnion("type", [
71
69
  r,
72
70
  o
73
- ]), C = t.union([
71
+ ]), U = t.discriminatedUnion("type", [
72
+ s,
73
+ o
74
+ ]), V = t.union([
74
75
  t.string().startsWith("file:").transform((e, n) => ({ type: "relative", path: e.slice(5) })),
75
- j
76
- ]), A = t.union([
76
+ x
77
+ ]), z = t.union([
77
78
  t.string().transform((e, n) => e.startsWith("file:") ? { type: "relative", path: e.slice(5) } : { type: "explicit-string", content: e }),
78
- P
79
- ]), f = t.string().regex(
79
+ w
80
+ ]), p = t.string().regex(
80
81
  /^(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-]+)*))?$/,
81
82
  "Wrong version format, please use valid semver"
82
83
  );
83
- function m(e) {
84
+ function y(e) {
84
85
  const n = e.endsWith("/") ? e : `${e}/`;
85
- return (s) => s.type === "relative" ? { type: "absolute-url", url: n + s.path } : s;
86
+ return (i) => i.type === "relative" ? { type: "absolute-url", url: n + i.path } : i;
86
87
  }
87
- function et(e) {
88
+ function at(e) {
88
89
  const n = e.endsWith("/") ? e : `${e}/`;
89
- return (s) => s.type === "relative" ? { type: "relative", path: n + s.path } : s;
90
+ return (i) => i.type === "relative" ? { type: "relative", path: n + i.path } : i;
90
91
  }
91
92
  const a = t.object({
92
93
  organization: t.string(),
93
94
  name: t.string(),
94
- version: f
95
- }).strict(), nt = a.omit({ version: !0 });
96
- function ot(e, n) {
95
+ version: p
96
+ }).strict(), M = a.omit({ version: !0 });
97
+ function lt(e) {
98
+ if (e !== void 0)
99
+ return `${e.organization}:${e.name}:${e.version}`;
100
+ }
101
+ function dt(e) {
102
+ if (e !== void 0)
103
+ return `${e.organization}:${e.name}`;
104
+ }
105
+ function gt(e, n) {
97
106
  return e === void 0 && n === void 0 ? !0 : e === void 0 || n === void 0 ? !1 : e.name === n.name && e.organization === n.organization && e.version === n.version;
98
107
  }
99
- function it(e, n) {
108
+ function mt(e, n) {
100
109
  return e === void 0 && n === void 0 ? !0 : e === void 0 || n === void 0 ? !1 : e.name === n.name && e.organization === n.organization;
101
110
  }
102
- function u(e) {
111
+ function f(e) {
103
112
  return t.object({
104
113
  type: t.literal("workflow-v1"),
105
114
  main: e.describe("Main workflow")
106
115
  });
107
116
  }
108
- function x(e) {
117
+ function S(e) {
109
118
  return t.union([
110
119
  // string is converted to v1 workflow
111
120
  e.transform((n) => ({
112
121
  type: "workflow-v1",
113
122
  main: n
114
- })).pipe(u(e)),
123
+ })).pipe(f(e)),
115
124
  // structured objects are decoded as union with type descriptor
116
- t.discriminatedUnion("type", [u(e)])
125
+ t.discriminatedUnion("type", [f(e)])
117
126
  ]);
118
127
  }
119
- function g(e, n) {
128
+ function u(e, n) {
120
129
  return t.object({
121
- workflow: x(e),
130
+ workflow: S(e),
122
131
  model: e,
123
132
  ui: n
124
133
  });
125
134
  }
126
- const k = g(t.string(), t.string());
127
- function rt(e) {
128
- return g(
129
- p.transform(m(e)),
130
- p.transform(m(e))
135
+ const h = u(t.string(), t.string());
136
+ function pt(e) {
137
+ return u(
138
+ m.transform(y(e)),
139
+ m.transform(y(e))
131
140
  );
132
141
  }
133
142
  function d(e, n) {
@@ -153,154 +162,197 @@ function d(e, n) {
153
162
  marketplaceRanking: t.number().optional()
154
163
  });
155
164
  }
156
- const b = d(
157
- A,
158
- C
159
- ), st = d(
165
+ const B = d(
166
+ z,
167
+ V
168
+ ), ut = d(
160
169
  t.string(),
161
- i
162
- ), w = d(
170
+ r
171
+ ), C = d(
163
172
  t.string(),
164
- B
165
- ), ct = t.object({
166
- components: k,
167
- meta: b
173
+ A
174
+ ), yt = t.object({
175
+ components: h,
176
+ meta: B
168
177
  });
169
- function v(e, n) {
178
+ function P(e, n) {
170
179
  return t.object({
171
180
  id: a,
172
181
  components: e,
173
182
  meta: n
174
183
  });
175
184
  }
176
- const at = v(
177
- k,
178
- b
179
- ), U = g(o, o), M = d(R, p), z = v(
180
- U,
181
- M
182
- ), S = t.string().regex(/[0-9a-fA-F]/).toUpperCase().length(64), D = t.object({
185
+ const ft = P(
186
+ h,
187
+ B
188
+ );
189
+ function kt(e, n) {
190
+ return v.mergeDeep(e, { id: { version: n } });
191
+ }
192
+ const D = u(o, o), I = d(U, m), E = P(
193
+ D,
194
+ I
195
+ ), L = t.string().regex(/[0-9a-fA-F]/).toUpperCase().length(64), T = t.object({
183
196
  name: t.string(),
184
197
  size: t.number().int(),
185
- sha256: S
186
- }), lt = t.object({
198
+ sha256: L
199
+ }), vt = t.object({
187
200
  schema: t.literal("v2"),
188
- description: z,
189
- files: t.array(D)
190
- }), dt = "manifest.json", E = t.object({
201
+ description: E,
202
+ timestamp: t.number().optional(),
203
+ files: t.array(T)
204
+ }), bt = "manifest.json";
205
+ function ht(e, n) {
206
+ return v.mergeDeep(e, { description: { id: { version: n } } });
207
+ }
208
+ const F = t.object({
191
209
  type: t.literal("dev-v1"),
192
210
  folder: t.string(),
193
211
  mtime: t.string().optional()
194
- }), V = t.object({
212
+ }), W = t.object({
195
213
  type: t.literal("dev-v2"),
196
214
  folder: t.string(),
197
215
  mtime: t.string().optional()
198
- }), F = t.object({
216
+ }), O = t.object({
199
217
  type: t.literal("from-registry-v1"),
200
218
  registryUrl: t.string(),
201
219
  id: a
202
- }), I = t.object({
220
+ }), $ = t.object({
203
221
  type: t.literal("from-registry-v2"),
204
222
  registryUrl: t.string(),
205
- id: a
206
- }), L = t.discriminatedUnion("type", [
207
- E,
208
- V,
223
+ id: a,
224
+ channel: t.string().optional()
225
+ }), j = t.discriminatedUnion("type", [
209
226
  F,
210
- I
211
- ]), W = t.object({
227
+ W,
228
+ O,
229
+ $
230
+ ]), Z = t.object({
212
231
  type: t.literal("local-dev"),
213
232
  path: t.string()
214
- }), T = t.object({
233
+ }), _ = t.object({
215
234
  type: t.literal("remote-v1"),
216
235
  url: t.string().url()
217
- }), Z = t.object({
236
+ }), q = t.object({
218
237
  type: t.literal("remote-v2"),
219
238
  url: t.string().url()
220
- }), O = t.discriminatedUnion("type", [
221
- T,
222
- Z,
223
- W
224
- ]), h = t.object({
239
+ }), N = t.discriminatedUnion("type", [
240
+ _,
241
+ q,
242
+ Z
243
+ ]), R = t.object({
225
244
  id: t.string(),
226
245
  title: t.string().optional(),
227
- spec: O
228
- }), pt = t.array(h), _ = t.object({
246
+ spec: N
247
+ }), Bt = t.array(R), Ct = t.object({
229
248
  registryId: t.string(),
230
249
  id: a,
231
- meta: w,
232
- spec: L,
233
- otherVersions: t.array(f)
234
- }), q = h.extend({
250
+ meta: C,
251
+ spec: j,
252
+ otherVersions: t.array(p)
253
+ }), G = "any", k = "stable", J = t.object({
254
+ version: p,
255
+ channels: t.array(t.string())
256
+ }), H = t.object({
257
+ id: a,
258
+ meta: C,
259
+ spec: j
260
+ }), K = t.object({
261
+ id: M,
262
+ latestByChannel: t.record(t.string(), H),
263
+ allVersions: t.array(J),
264
+ registryId: t.string()
265
+ }), Q = R.extend({
235
266
  status: t.union([t.literal("online"), t.literal("offline")])
236
- }), gt = t.object({
237
- registries: t.array(q),
238
- blockPacks: t.array(_)
239
- }), mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
267
+ }), Pt = t.object({
268
+ registries: t.array(Q),
269
+ blockPacks: t.array(K)
270
+ });
271
+ function jt(e) {
272
+ const n = e.latestByChannel[k] !== void 0 ? k : G, i = e.latestByChannel[n];
273
+ return {
274
+ id: i.id,
275
+ meta: i.meta,
276
+ spec: i.spec,
277
+ otherVersions: e.allVersions.filter((g) => g.channels.indexOf(n) >= 0).map((g) => g.version),
278
+ registryId: e.registryId
279
+ };
280
+ }
281
+ const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
240
282
  __proto__: null
241
283
  }, Symbol.toStringTag, { value: "Module" }));
242
284
  export {
243
- g as BlockComponents,
244
- rt as BlockComponentsAbsoluteUrl,
245
- k as BlockComponentsDescriptionRaw,
246
- U as BlockComponentsManifest,
247
- ct as BlockPackDescriptionFromPackageJsonRaw,
248
- z as BlockPackDescriptionManifest,
249
- at as BlockPackDescriptionRaw,
250
- E as BlockPackDevV1,
251
- V as BlockPackDevV2,
252
- F as BlockPackFromRegistryV1,
253
- I as BlockPackFromRegistryV2,
285
+ G as AnyChannel,
286
+ u as BlockComponents,
287
+ pt as BlockComponentsAbsoluteUrl,
288
+ h as BlockComponentsDescriptionRaw,
289
+ D as BlockComponentsManifest,
290
+ yt as BlockPackDescriptionFromPackageJsonRaw,
291
+ E as BlockPackDescriptionManifest,
292
+ ft as BlockPackDescriptionRaw,
293
+ F as BlockPackDevV1,
294
+ W as BlockPackDevV2,
295
+ O as BlockPackFromRegistryV1,
296
+ $ as BlockPackFromRegistryV2,
254
297
  a as BlockPackId,
255
- nt as BlockPackIdNoVersion,
256
- gt as BlockPackListing,
257
- lt as BlockPackManifest,
258
- dt as BlockPackManifestFile,
298
+ M as BlockPackIdNoVersion,
299
+ Pt as BlockPackListing,
300
+ vt as BlockPackManifest,
301
+ bt as BlockPackManifestFile,
259
302
  d as BlockPackMeta,
260
- b as BlockPackMetaDescriptionRaw,
261
- st as BlockPackMetaEmbeddedBase64,
262
- w as BlockPackMetaEmbeddedBytes,
263
- M as BlockPackMetaManifest,
264
- _ as BlockPackOverview,
265
- L as BlockPackSpec,
266
- X as ContentAbsoluteBinaryLocal,
267
- Q as ContentAbsoluteBinaryRemote,
303
+ B as BlockPackMetaDescriptionRaw,
304
+ ut as BlockPackMetaEmbeddedBase64,
305
+ C as BlockPackMetaEmbeddedBytes,
306
+ I as BlockPackMetaManifest,
307
+ K as BlockPackOverview,
308
+ Ct as BlockPackOverviewLegacy,
309
+ j as BlockPackSpec,
310
+ rt as ContentAbsoluteBinaryLocal,
311
+ ot as ContentAbsoluteBinaryRemote,
268
312
  c as ContentAbsoluteFile,
269
- N as ContentAbsoluteFolder,
270
- tt as ContentAbsoluteTextLocal,
271
- Y as ContentAbsoluteTextRemote,
313
+ Y as ContentAbsoluteFolder,
314
+ ct as ContentAbsoluteTextLocal,
315
+ st as ContentAbsoluteTextRemote,
272
316
  l as ContentAbsoluteUrl,
273
- G as ContentAny,
274
- j as ContentAnyBinaryLocal,
275
- H as ContentAnyLocal,
276
- K as ContentAnyRemote,
277
- P as ContentAnyTextLocal,
278
- i as ContentExplicitBase64,
279
- B as ContentExplicitBytes,
280
- J as ContentExplicitOrRelative,
281
- r as ContentExplicitString,
317
+ tt as ContentAny,
318
+ x as ContentAnyBinaryLocal,
319
+ nt as ContentAnyLocal,
320
+ it as ContentAnyRemote,
321
+ w as ContentAnyTextLocal,
322
+ r as ContentExplicitBase64,
323
+ A as ContentExplicitBytes,
324
+ et as ContentExplicitOrRelative,
325
+ s as ContentExplicitString,
282
326
  o as ContentRelative,
283
- p as ContentRelativeBinary,
284
- R as ContentRelativeText,
285
- v as CreateBlockPackDescriptionSchema,
286
- C as DescriptionContentBinary,
287
- A as DescriptionContentText,
288
- W as LocalDevFolder,
289
- D as ManifestFileInfo,
290
- mt as PFrameInternal,
291
- h as RegistryEntry,
292
- pt as RegistryList,
293
- O as RegistrySpec,
294
- q as RegistryStatus,
295
- T as RemoteRegistryV1Spec,
296
- Z as RemoteRegistryV2Spec,
297
- f as SemVer,
298
- S as Sha256Schema,
299
- x as Workflow,
300
- u as WorkflowV1,
301
- et as addPrefixToRelative,
302
- ot as blockPackIdEquals,
303
- it as blockPackIdNoVersionEquals,
304
- m as mapRemoteToAbsolute
327
+ m as ContentRelativeBinary,
328
+ U as ContentRelativeText,
329
+ P as CreateBlockPackDescriptionSchema,
330
+ V as DescriptionContentBinary,
331
+ z as DescriptionContentText,
332
+ Z as LocalDevFolder,
333
+ T as ManifestFileInfo,
334
+ Rt as PFrameInternal,
335
+ R as RegistryEntry,
336
+ Bt as RegistryList,
337
+ N as RegistrySpec,
338
+ Q as RegistryStatus,
339
+ _ as RemoteRegistryV1Spec,
340
+ q as RemoteRegistryV2Spec,
341
+ p as SemVer,
342
+ L as Sha256Schema,
343
+ H as SingleBlockPackOverview,
344
+ k as StableChannel,
345
+ J as VersionWithChannels,
346
+ S as Workflow,
347
+ f as WorkflowV1,
348
+ at as addPrefixToRelative,
349
+ gt as blockPackIdEquals,
350
+ mt as blockPackIdNoVersionEquals,
351
+ dt as blockPackIdNoVersionToString,
352
+ lt as blockPackIdToString,
353
+ jt as blockPackOverviewToLegacy,
354
+ y as mapRemoteToAbsolute,
355
+ kt as overrideDescriptionVersion,
356
+ ht as overrideManifestVersion
305
357
  };
306
358
  //# sourceMappingURL=index.mjs.map