@luna-park/plugin 1.5.0 → 1.5.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/bin/preview.js CHANGED
@@ -1,50 +1,50 @@
1
- #!/usr/bin/env node
2
- import { parseArgs } from "node:util";
3
-
4
- import { resolve } from "path";
5
-
6
- import { startPreviewServer } from "../dist/preview.mjs";
7
-
8
- const cwd = process.cwd();
9
-
10
- // Parse CLI arguments
11
- const { values } = parseArgs({
12
- options: {
13
- dist: {
14
- default: "dist",
15
- short: "d",
16
- type: "string"
17
- },
18
- help: {
19
- default: false,
20
- short: "h",
21
- type: "boolean"
22
- },
23
- port: {
24
- default: "2084",
25
- short: "p",
26
- type: "string"
27
- }
28
- }
29
- });
30
-
31
- if (values.help) {
32
- console.log(`
33
- Usage: luna-preview [options]
34
-
35
- Options:
36
- -p, --port <port> Port to run the server on (default: 2084)
37
- -d, --dist <dir> Distribution directory to serve (default: dist)
38
- -h, --help Show this help message
39
- `);
40
- process.exit(0);
41
- }
42
-
43
- const dist = resolve(cwd, values.dist);
44
- const port = parseInt(values.port);
45
-
46
- startPreviewServer({
47
- dist,
48
- externals: ["vue", "vue-router", "@luna-park/design"],
49
- port
50
- });
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from "node:util";
3
+
4
+ import { resolve } from "path";
5
+
6
+ import { startPreviewServer } from "../dist/preview.mjs";
7
+
8
+ const cwd = process.cwd();
9
+
10
+ // Parse CLI arguments
11
+ const { values } = parseArgs({
12
+ options: {
13
+ dist: {
14
+ default: "dist",
15
+ short: "d",
16
+ type: "string"
17
+ },
18
+ help: {
19
+ default: false,
20
+ short: "h",
21
+ type: "boolean"
22
+ },
23
+ port: {
24
+ default: "2084",
25
+ short: "p",
26
+ type: "string"
27
+ }
28
+ }
29
+ });
30
+
31
+ if (values.help) {
32
+ console.log(`
33
+ Usage: luna-preview [options]
34
+
35
+ Options:
36
+ -p, --port <port> Port to run the server on (default: 2084)
37
+ -d, --dist <dir> Distribution directory to serve (default: dist)
38
+ -h, --help Show this help message
39
+ `);
40
+ process.exit(0);
41
+ }
42
+
43
+ const dist = resolve(cwd, values.dist);
44
+ const port = parseInt(values.port);
45
+
46
+ startPreviewServer({
47
+ dist,
48
+ externals: ["vue", "vue-router", "@luna-park/design"],
49
+ port
50
+ });
@@ -448,6 +448,11 @@ function cleanUnion(schema) {
448
448
  }
449
449
  function cleanInterface(schema) {
450
450
  if (schema.className === "Array") return LogicType.array(schema.options.template[0]);
451
+ if (schema.className === "Type" && schema.options?.template?.[0]?.enum?.length) {
452
+ const reference = schema.options.template[0].enum[0];
453
+ const target = (Array.isArray(reference) ? reference.join("") : String(reference)).split("/");
454
+ return LogicType.type(target, schema.optional ? { optional: true } : {});
455
+ }
451
456
  if (schema.className === "keyof") return LogicType.string();
452
457
  if (schema.className === "Record") return LogicType.object({});
453
458
  if (schema.className === "PropertyKey") return LogicType.union([LogicType.string(), LogicType.number()]);
@@ -1,4 +1,4 @@
1
- import { l as TSchema } from "./index-DwEOlEBY.mjs";
1
+ import { l as TSchema } from "./index-DQhxmFHB.mjs";
2
2
  import * as ts$1 from "typescript";
3
3
  import ts from "typescript";
4
4
  //#region src/extractor/export/type.d.ts
@@ -1,4 +1,4 @@
1
- import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-JzydDdZn.mjs";
1
+ import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-Cnje_ZD3.mjs";
2
2
  import fs from "node:fs";
3
3
  import * as ts$1 from "typescript";
4
4
  import ts from "typescript";
@@ -243,6 +243,7 @@ type TNodeDisplay = {
243
243
  hoverable?: boolean;
244
244
  icon?: string | IconDefinition;
245
245
  inspector?: string;
246
+ interfaceBelow?: boolean;
246
247
  noDelete?: boolean;
247
248
  noSelection?: boolean;
248
249
  notFound?: boolean;
@@ -284,6 +285,7 @@ type TNodeDynamics<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TN
284
285
  };
285
286
  type TDocumentation = {
286
287
  description?: string;
288
+ dynamics?: string;
287
289
  examples?: Array<{
288
290
  inputs: Array<{
289
291
  key: string;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LogicUtil, c as TObject, d as makeLogicNode, f as CVector, h as TVector, i as LogicType, l as TSchema, m as MaybePromise, n as ELogicType, o as Static, p as DeepPartial, r as EVarType, s as TLogicNode, t as ELogicScope, u as TVoid } from "./index-DwEOlEBY.mjs";
1
+ import { a as LogicUtil, c as TObject, d as makeLogicNode, f as CVector, h as TVector, i as LogicType, l as TSchema, m as MaybePromise, n as ELogicType, o as Static, p as DeepPartial, r as EVarType, s as TLogicNode, t as ELogicScope, u as TVoid } from "./index-DQhxmFHB.mjs";
2
2
  import "typescript";
3
3
  import { Component, ComputedRef } from "vue";
4
4
  import "@sinclair/typebox";
@@ -78,9 +78,29 @@ type TRouteGuard = {
78
78
  //#region src/types/hooks.d.ts
79
79
  export declare enum EPluginHooks {
80
80
  BackendMiddleware = "backend/middleware",
81
- BackendInputNode = "backend/input-node"
81
+ BackendInputNode = "backend/input-node",
82
+ DatabaseScope = "database/scope",
83
+ DatabaseChange = "database/change"
82
84
  }
85
+ type TDatabaseCondition = {
86
+ operation: string;
87
+ source: Array<string>;
88
+ target: unknown;
89
+ type: "value" | "column";
90
+ } | {
91
+ conditions: Array<TDatabaseCondition>;
92
+ type: "and" | "or";
93
+ };
83
94
  type THookParams = {
95
+ [EPluginHooks.DatabaseScope]: {
96
+ addConditions: (conditions: Array<TDatabaseCondition>) => void;
97
+ table: string;
98
+ };
99
+ [EPluginHooks.DatabaseChange]: {
100
+ operation: "insert" | "update" | "delete";
101
+ rows: Array<Record<string, unknown>>;
102
+ table: string;
103
+ };
84
104
  [EPluginHooks.BackendMiddleware]: {
85
105
  cookies: Record<string, {
86
106
  options?: Record<string, unknown>;
@@ -109,7 +129,7 @@ type TExportNodeResult = {
109
129
  types: Record<string, TSchema>;
110
130
  };
111
131
  //#endregion
112
- //#region ../shared/dist/index-DloGTzVR.d.mts
132
+ //#region ../shared/dist/index-D4yemxKH.d.mts
113
133
  //#endregion
114
134
  //#region src/types/editor/wire.d.ts
115
135
  declare class CPathPoint {
@@ -284,7 +304,6 @@ type TRouteGuardRef = {
284
304
  };
285
305
  type TFileRoute<TExport extends boolean = false> = TFileBase<TExport> & {
286
306
  type: EElementType.Route;
287
- dev?: boolean;
288
307
  guards?: Array<TRouteGuardRef>;
289
308
  input: {
290
309
  body: TSchema;
@@ -330,19 +349,6 @@ type TFileStore<TExport extends boolean = false> = TFileBase<TExport> & {
330
349
  value: Record<string, unknown>;
331
350
  }>;
332
351
  //#endregion
333
- //#region src/layout/template.d.ts
334
- declare enum EElementTemplate {
335
- If = "if",
336
- For = "for"
337
- }
338
- declare enum ETemplatePreview {
339
- Display = "display",
340
- Hide = "hide",
341
- Real = "real",
342
- Once = "once",
343
- All = "all"
344
- }
345
- //#endregion
346
352
  //#region src/types/layout.d.ts
347
353
  type TTextBlock = {
348
354
  content: string;
@@ -359,10 +365,6 @@ type TLayoutContentType<TElement extends ELayoutElement, TExport extends boolean
359
365
  } : TElement extends ELayoutElement.customHtml ? {
360
366
  html: string;
361
367
  variables: Array<string>;
362
- } : TElement extends ELayoutElement.template ? {
363
- preview: ETemplatePreview;
364
- template: EElementTemplate;
365
- var: TMaybeDynamicVariable<TExport>;
366
368
  } : TElement extends ELayoutElement.package ? {
367
369
  slots: Record<string, TLayoutSchema<ELayoutElement, TExport>>;
368
370
  target: Array<string>;
@@ -380,6 +382,11 @@ type TLayoutStyle<TExport extends boolean = false> = {
380
382
  quick?: Array<string>;
381
383
  [media: `${number}`]: TLayoutStyleStates<TExport> | undefined;
382
384
  };
385
+ type TLayoutClass<TExport extends boolean = false> = {
386
+ id: string;
387
+ name: string;
388
+ style: TLayoutStyle<TExport>;
389
+ };
383
390
  type TLayoutEventParameter<TExport extends boolean = false> = {
384
391
  schema: TSchema;
385
392
  value: TMaybeDynamicVariable<TExport>;
@@ -393,7 +400,7 @@ type TLayoutSchema<TElement extends ELayoutElement = ELayoutElement, TExport ext
393
400
  content: TLayoutContentType<TInnerElement, TExport>;
394
401
  element: TInnerElement;
395
402
  events: Record<string, Record<string, TLayoutEventParameter<TExport>>>;
396
- model?: Array<string>;
403
+ models?: Record<string, Array<string>>;
397
404
  properties: Record<string, TMaybeDynamicVariable<TExport>>;
398
405
  style: TLayoutStyle<TExport>;
399
406
  tag?: string;
@@ -578,6 +585,7 @@ type TCanvas = {
578
585
  zoom: number;
579
586
  };
580
587
  type TGraph<TExport extends boolean = false> = {
588
+ autoplace?: boolean;
581
589
  canvas: TCanvas;
582
590
  nodes: Record<string, TNode<TExport>>;
583
591
  wires: Record<string, TWire<TExport>>;
@@ -808,6 +816,7 @@ type TComponentOptions = {
808
816
  };
809
817
  type TFileComponent<TExport extends boolean = false> = TFileBase<TExport> & {
810
818
  type: EElementType.Component;
819
+ classes?: Record<string, TLayoutClass<TExport>>;
811
820
  collapsed?: boolean;
812
821
  layout: TLayoutSchema<ELayoutElement, TExport>;
813
822
  logics: Record<string, TAnyLogic<TExport>>;
@@ -829,39 +838,40 @@ declare enum EDynamicVariableType {
829
838
  Dynamic = "dynamic",
830
839
  Token = "token"
831
840
  }
832
- declare enum EDynamicVariableOperation {
833
- Identity = "identity",
841
+ declare enum EDynamicOperation {
834
842
  Equal = "equal",
835
843
  NotEqual = "not-equal",
836
844
  Greater = "greater",
837
- Less = "less",
838
845
  GreaterEqual = "greater-equal",
846
+ Less = "less",
839
847
  LessEqual = "less-equal",
840
848
  StartsWith = "starts-with",
841
849
  EndsWith = "ends-with",
842
850
  Includes = "includes",
843
- Ternary = "ternary",
844
- Cast = "cast",
845
851
  At = "at",
846
- Join = "join"
847
- }
848
- declare enum EDynamicVariableChain {
852
+ Join = "join",
853
+ ToLowerCase = "to-lower-case",
854
+ Length = "length",
855
+ Not = "not",
856
+ And = "and",
857
+ Or = "or",
849
858
  Add = "add",
850
859
  Subtract = "subtract",
851
860
  Multiply = "multiply",
852
861
  Divide = "divide",
853
862
  Modulo = "modulo",
854
- And = "and",
855
- Or = "or"
863
+ Ternary = "ternary",
864
+ ToString = "to-string",
865
+ ToNumber = "to-number",
866
+ ToBoolean = "to-boolean",
867
+ Call = "call"
856
868
  }
857
- type TDynamicVariableTarget = {
858
- chainMode?: EVarType;
859
- chainVariables?: Array<{
860
- operation: EDynamicVariableChain;
861
- value: TMaybeDynamicVariable<true>;
862
- }>;
863
- mode?: EVarType;
864
- operation: EDynamicVariableOperation;
869
+ /**
870
+ * One operation applied to the previous value, optionally followed by a property access on its result.
871
+ */
872
+ type TDynamicVariableStep = {
873
+ access?: Array<string>;
874
+ operation: EDynamicOperation;
865
875
  variables: Array<TMaybeDynamicVariable<true>>;
866
876
  };
867
877
  /**
@@ -871,7 +881,7 @@ type TBaseDynamicVariable = {
871
881
  type: EDynamicVariableType;
872
882
  _dynamic: true;
873
883
  access: Array<string>;
874
- target?: TDynamicVariableTarget;
884
+ steps?: Array<TDynamicVariableStep>;
875
885
  token: string;
876
886
  value: unknown;
877
887
  };
@@ -955,6 +965,7 @@ type TBasePlugin<TConfig extends TSchema = TSchema, TInternals = unknown> = {
955
965
  name: string;
956
966
  version?: string;
957
967
  }>;
968
+ env?: Record<string, string>;
958
969
  frontImports?: Array<{
959
970
  name: string;
960
971
  version?: string;
@@ -1020,6 +1031,7 @@ type TEnv<TConfig extends TSchema = TSchema, TInternals = unknown> = {
1020
1031
  config: Static<TConfig>;
1021
1032
  getFile: (id: string) => TFile | undefined;
1022
1033
  internals: TInternals;
1034
+ log: (message: string, severity?: "info" | "warning" | "error") => void;
1023
1035
  mode: "build" | "editor";
1024
1036
  };
1025
1037
  type TOption<TParams = unknown, TResult = unknown> = TResult | ((env: TParams) => Promise<TResult> | TResult);
@@ -1030,4 +1042,4 @@ export declare function makeComponent<TProps extends Record<string, TSchema>>(co
1030
1042
  export declare function loadPlugin<TConfig extends TSchema, TInternal>(plugin: TPlugin<TConfig, TInternal>, env: Partial<TEnv>): Promise<TBasePlugin<TConfig, TInternal>>;
1031
1043
  export declare function getPluginParam<T>(target: TOption<TEnv, T>, env: Partial<TEnv>): Promise<T>;
1032
1044
  //#endregion
1033
- export { EElementType, ELogicScope, ELogicType, EVarType, _default as LSettingsStoryWrapper, LogicType, LogicUtil, type Static, type TAnyLogic, type TApplication, type TBasePlugin, type TComponent, type TEnv, type TFile, type TFileComponent, type TFileConfig, type TFileCron, type TFileDatabase, type TFileMedia, type TFileRoute, type TFileScript, type TFileStore, type TFileText, type TFileType, type TFolder, type THookParams, type TLogic, type TLogicMain, type TLogicNode, type TOption, type TPlugin, type TProxyPlugin, type TRouteGuard, type TSchema, type TSlot, type TTemplate, type TToken, makeLogicNode };
1045
+ export { EElementType, ELogicScope, ELogicType, EVarType, _default as LSettingsStoryWrapper, LogicType, LogicUtil, type Static, type TAnyLogic, type TApplication, type TBasePlugin, type TComponent, type TDatabaseCondition, type TEnv, type TFile, type TFileComponent, type TFileConfig, type TFileCron, type TFileDatabase, type TFileMedia, type TFileRoute, type TFileScript, type TFileStore, type TFileText, type TFileType, type TFolder, type THookParams, type TLogic, type TLogicMain, type TLogicNode, type TOption, type TPlugin, type TProxyPlugin, type TRouteGuard, type TSchema, type TSlot, type TTemplate, type TToken, makeLogicNode };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LogicUtil, i as LogicType, n as ELogicType, o as makeLogicNode, r as EVarType, t as ELogicScope, u as cloneWithFunctions } from "./dist-JzydDdZn.mjs";
1
+ import { a as LogicUtil, i as LogicType, n as ELogicType, o as makeLogicNode, r as EVarType, t as ELogicScope, u as cloneWithFunctions } from "./dist-Cnje_ZD3.mjs";
2
2
  import { createElementBlock, openBlock, renderSlot } from "vue";
3
3
  import { Type } from "@sinclair/typebox";
4
4
  //#region \0/plugin-vue/export-helper
@@ -20,6 +20,8 @@ var LSettingsStoryWrapper_default = /*#__PURE__*/ export_helper_default(_sfc_mai
20
20
  let EPluginHooks = /* @__PURE__ */ function(EPluginHooks) {
21
21
  EPluginHooks["BackendMiddleware"] = "backend/middleware";
22
22
  EPluginHooks["BackendInputNode"] = "backend/input-node";
23
+ EPluginHooks["DatabaseScope"] = "database/scope";
24
+ EPluginHooks["DatabaseChange"] = "database/change";
23
25
  return EPluginHooks;
24
26
  }({});
25
27
  //#endregion
@@ -908,6 +910,46 @@ function getContent(response) {
908
910
  if (response.headers.get("Content-Type")?.startsWith("application/json")) return response.json();
909
911
  return response.text();
910
912
  }
913
+ function isSchemaType(schema, ...types) {
914
+ if (schema?.type === EVarType.union) return schema.elements.length > 0 && schema.elements.every((element) => isSchemaType(element, ...types));
915
+ return Boolean(schema && types.includes(schema.type));
916
+ }
917
+ function strip(schema) {
918
+ const result = { ...schema };
919
+ delete result.default;
920
+ delete result.name;
921
+ delete result.optional;
922
+ return result;
923
+ }
924
+ function named(schema, name) {
925
+ return {
926
+ ...strip(schema),
927
+ name
928
+ };
929
+ }
930
+ function binary(operator, precedence, types, evaluate, output) {
931
+ return {
932
+ accepts: (input) => isSchemaType(input, ...types),
933
+ argPrecedence: precedence + 1,
934
+ args: (input) => [named(input, "Value")],
935
+ evaluate,
936
+ inputPrecedence: precedence,
937
+ output: output ?? ((input) => strip(input)),
938
+ precedence,
939
+ print: (input, [arg]) => `${input} ${operator} ${arg}`
940
+ };
941
+ }
942
+ function comparison(operator, precedence, types, evaluate) {
943
+ return binary(operator, precedence, types, evaluate, () => LogicType.boolean());
944
+ }
945
+ const primitives = [
946
+ EVarType.boolean,
947
+ EVarType.number,
948
+ EVarType.string,
949
+ EVarType.unknown
950
+ ];
951
+ const ordered = [EVarType.number, EVarType.string];
952
+ comparison("===", 8, primitives, (input, [arg]) => input === arg), comparison("!==", 8, primitives, (input, [arg]) => input !== arg), comparison(">", 9, ordered, (input, [arg]) => input > arg), comparison(">=", 9, ordered, (input, [arg]) => input >= arg), comparison("<", 9, ordered, (input, [arg]) => input < arg), comparison("<=", 9, ordered, (input, [arg]) => input <= arg), binary("&&", 4, [EVarType.boolean], (input, [arg]) => Boolean(input && arg)), binary("||", 3, primitives, (input, [arg]) => input || arg), binary("+", 11, [EVarType.number, EVarType.string], (input, [arg]) => input + arg), binary("-", 11, [EVarType.number], (input, [arg]) => input - arg), binary("*", 12, [EVarType.number], (input, [arg]) => input * arg), binary("/", 12, [EVarType.number], (input, [arg]) => input / arg), binary("%", 12, [EVarType.number], (input, [arg]) => input % arg), EVarType.boolean, EVarType.number, EVarType.unknown, LogicType.string(), EVarType.boolean, EVarType.string, EVarType.unknown, LogicType.number(), EVarType.number, EVarType.string, EVarType.unknown, LogicType.boolean();
911
953
  //#endregion
912
954
  //#region src/index.ts
913
955
  function makePlugin(plugin) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luna-park/plugin",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "private": false,
5
5
  "description": "Plugin helper for Luna Park.",
6
6
  "homepage": "https://luna-park.app",