@pylonts/dsl 1.1.12 → 1.1.13

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.
Files changed (48) hide show
  1. package/dist/convert.d.ts +6 -8
  2. package/dist/curd.js +1 -1
  3. package/dist/dao.d.ts +10 -7
  4. package/dist/dao.js +20 -7
  5. package/dist/dsl.d.ts +18 -1
  6. package/dist/dsl.js +40 -0
  7. package/dist/dto.d.ts +13 -8
  8. package/dist/dto.js +68 -13
  9. package/dist/entity.d.ts +4 -3
  10. package/dist/entity.js +1 -1
  11. package/dist/filter.d.ts +6 -4
  12. package/dist/filter.js +1 -1
  13. package/dist/flow-script.js +8 -2
  14. package/dist/flow.d.ts +10 -2
  15. package/dist/flow.js +44 -4
  16. package/dist/mermaid-driver.js +2 -2
  17. package/dist/service.d.ts +13 -8
  18. package/dist/service.js +1 -1
  19. package/dist/third-service.d.ts +10 -53
  20. package/dist/third-service.js +3 -78
  21. package/dist/typebox-driver.d.ts +0 -6
  22. package/dist/typebox-driver.js +8 -36
  23. package/dist/utils.d.ts +2 -2
  24. package/docs/curd.md +146 -146
  25. package/docs/dao-generation.md +477 -477
  26. package/docs/project.md +31 -31
  27. package/docs/token.md +326 -326
  28. package/package.json +1 -1
  29. package/src/action.ts +51 -51
  30. package/src/controller.ts +53 -53
  31. package/src/convert.ts +76 -78
  32. package/src/curd.ts +104 -104
  33. package/src/dao.ts +504 -485
  34. package/src/dsl.ts +296 -257
  35. package/src/dto.ts +323 -266
  36. package/src/entity.ts +43 -42
  37. package/src/expr.ts +64 -64
  38. package/src/filter.ts +71 -69
  39. package/src/flow-script.ts +702 -695
  40. package/src/flow.ts +1272 -1226
  41. package/src/index.ts +46 -46
  42. package/src/mermaid-driver.ts +339 -339
  43. package/src/mysql-driver.ts +108 -108
  44. package/src/project.ts +138 -138
  45. package/src/service.ts +112 -107
  46. package/src/third-service.ts +68 -191
  47. package/src/typebox-driver.ts +234 -268
  48. package/src/utils.ts +74 -74
package/src/utils.ts CHANGED
@@ -1,75 +1,75 @@
1
- import type { Field, SchemaBase } from './dsl.js';
2
- import type { FrontAppSchema, ProjectApiSchema } from './project.js';
3
-
4
- // Base utility modules — business-agnostic helpers with full method
5
- // signatures (e.g. DateTimeUtils.format). Called at the service layer;
6
- // their args/results are own wire types, independent of business schemas.
7
-
8
- /** A utility method with a full signature. */
9
- export interface UtilsMethodSchema extends SchemaBase {
10
- type: 'utilsMethod';
11
- /** The utility module this method belongs to. */
12
- schema: UtilsSchema;
13
- /** Input fields. */
14
- args: Record<string, Field>;
15
- /** Output field. */
16
- result: Field;
17
- }
18
-
19
- /** Method input for defineUtils: type/schema/name are set by the builder. */
20
- export type UtilsMethodDef = Omit<UtilsMethodSchema, 'type' | 'schema' | 'name'>;
21
-
22
- /** A base utility module (e.g. DateTimeUtils). */
23
- export interface UtilsSchema extends SchemaBase {
24
- type: 'utils';
25
- /** Backend binding — the api module this utils belongs to (shared instance
26
- * from project.config.ts apis). With `app` it serves that frontend
27
- * ({api}/{app}/utils/); alone it is the api's public module
28
- * ({api}/common/utils/). Unset = not backend-side. */
29
- api?: ProjectApiSchema;
30
- /** Optional binding — the frontend app this utils serves (shared instance
31
- * from project.config.ts apps). Empty means a shared public module. */
32
- app?: FrontAppSchema;
33
- /** Methods keyed by name — the map key is written back as the method name. */
34
- methods: Record<string, UtilsMethodSchema>;
35
- }
36
-
37
- export function defineUtils(options: {
38
- name: string;
39
- api?: ProjectApiSchema;
40
- app?: FrontAppSchema;
41
- methods: Record<string, UtilsMethodDef>;
42
- description?: string;
43
- }): UtilsSchema {
44
- if (options.api !== undefined && options.app !== undefined && !options.api.apps.includes(options.app)) {
45
- throw new Error(`utils ${options.name}: api '${options.api.name}' does not serve app '${options.app.name}'`);
46
- }
47
- const schema: UtilsSchema = {
48
- type: 'utils',
49
- name: options.name,
50
- description: options.description,
51
- api: options.api,
52
- app: options.app,
53
- methods: {},
54
- };
55
- for (const key of Object.keys(options.methods)) {
56
- const method = options.methods[key] as UtilsMethodDef;
57
- const methodSchema: UtilsMethodSchema = {
58
- type: 'utilsMethod',
59
- name: key,
60
- description: method.description,
61
- schema,
62
- args: method.args,
63
- result: method.result,
64
- };
65
- for (const argKey of Object.keys(methodSchema.args)) {
66
- const field = methodSchema.args[argKey] as Field;
67
- field.name = argKey;
68
- field.schema = methodSchema;
69
- }
70
- methodSchema.result.name = key;
71
- methodSchema.result.schema = methodSchema;
72
- schema.methods[key] = methodSchema;
73
- }
74
- return schema;
1
+ import type { CollectionSchemaBase, Field, SchemaBase } from './dsl.js';
2
+ import type { FrontAppSchema, ProjectApiSchema } from './project.js';
3
+
4
+ // Base utility modules — business-agnostic helpers with full method
5
+ // signatures (e.g. DateTimeUtils.format). Called at the service layer;
6
+ // their args/results are own wire types, independent of business schemas.
7
+
8
+ /** A utility method with a full signature. */
9
+ export interface UtilsMethodSchema extends SchemaBase {
10
+ type: 'utilsMethod';
11
+ /** The utility module this method belongs to. */
12
+ schema: UtilsSchema;
13
+ /** Input fields. */
14
+ args: Record<string, Field>;
15
+ /** Output field. */
16
+ result: Field;
17
+ }
18
+
19
+ /** Method input for defineUtils: type/schema/name are set by the builder. */
20
+ export type UtilsMethodDef = Omit<UtilsMethodSchema, 'type' | 'schema' | 'name'>;
21
+
22
+ /** A base utility module (e.g. DateTimeUtils). */
23
+ export interface UtilsSchema extends CollectionSchemaBase {
24
+ type: 'utils';
25
+ /** Backend binding — the api module this utils belongs to (shared instance
26
+ * from project.config.ts apis). With `app` it serves that frontend
27
+ * ({api}/{app}/utils/); alone it is the api's public module
28
+ * ({api}/common/utils/). Unset = not backend-side. */
29
+ api?: ProjectApiSchema;
30
+ /** Optional binding — the frontend app this utils serves (shared instance
31
+ * from project.config.ts apps). Empty means a shared public module. */
32
+ app?: FrontAppSchema;
33
+ /** Methods keyed by name — the map key is written back as the method name. */
34
+ methods: Record<string, UtilsMethodSchema>;
35
+ }
36
+
37
+ export function defineUtils(options: {
38
+ name: string;
39
+ api?: ProjectApiSchema;
40
+ app?: FrontAppSchema;
41
+ methods: Record<string, UtilsMethodDef>;
42
+ description?: string;
43
+ }): UtilsSchema {
44
+ if (options.api !== undefined && options.app !== undefined && !options.api.apps.includes(options.app)) {
45
+ throw new Error(`utils ${options.name}: api '${options.api.name}' does not serve app '${options.app.name}'`);
46
+ }
47
+ const schema: UtilsSchema = {
48
+ type: 'utils',
49
+ name: options.name,
50
+ description: options.description,
51
+ api: options.api,
52
+ app: options.app,
53
+ methods: {},
54
+ };
55
+ for (const key of Object.keys(options.methods)) {
56
+ const method = options.methods[key] as UtilsMethodDef;
57
+ const methodSchema: UtilsMethodSchema = {
58
+ type: 'utilsMethod',
59
+ name: key,
60
+ description: method.description,
61
+ schema,
62
+ args: method.args,
63
+ result: method.result,
64
+ };
65
+ for (const argKey of Object.keys(methodSchema.args)) {
66
+ const field = methodSchema.args[argKey] as Field;
67
+ field.name = argKey;
68
+ field.schema = methodSchema;
69
+ }
70
+ methodSchema.result.name = key;
71
+ methodSchema.result.schema = methodSchema;
72
+ schema.methods[key] = methodSchema;
73
+ }
74
+ return schema;
75
75
  }